如何从JSON中完全删除属性?

时间:2018-03-13 14:53:50

标签: json node.js steam steambot

所以这是我的代码,它在NodeJS而不是javascript:

       while (otn !== -1) {
     var li= inventory.length - 1;
     while (li !== -1){
       li = li- 1;
       if (inventory[li].market_name === orderitemname[otn]){
         console.log("Add item to trade " + orderitemname[otn]);
         offer.addMyItem(inventory[li]);
         console.log(inventory[li])
         delete inventory[li];
         //Close everything

所以一切正常,除delete inventory[li]之外,它的作用是从json中删除值,但是当while循环再次运行时,程序会尝试从同一个值中读取值和崩溃,所以有没有办法,我们可以完全删除它(以下一堆代码),然后甚至没有列出?顺便说一下,这是我的JSON:

CEconItem {
appid: 730,
contextid: '2',
assetid: '13799167798',
classid: '506854340',
instanceid: '188530139',
amount: 1,
pos: 1,
id: '13799167798',
background_color: '',
icon_url: blah,
icon_url_large: blah,
descriptions: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
tradable: true,
actions: [ [Object] ],
name: 'P90 | Module',
name_color: 'D2D2D2',
type: 'Mil-Spec Grade SMG',
market_name: 'P90 | Module (Factory New)',
market_hash_name: 'P90 | Module (Factory New)',
market_actions: [ [Object] ],
commodity: false,
market_tradable_restriction: 7,
marketable: true,
tags: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
is_currency: false,
market_marketable_restriction: 0,
fraudwarnings: [] },
And a lot of these...

非常感谢任何帮助:)谢谢!

PS:我是一个完整的noobie,如果我错过了像蛋糕一样简单的东西,请不要烤我:)

0 个答案:

没有答案