Saturday, 13 May 2017

Some JSON objects is undefined

So I'm working a bit with nodeJS and Steam API to try and make a trade bot I need to know what items was recieved, but when I do I get

undefined

Here's the JSON:

    {  
   "partner":{  
      "universe":1,
      "type":1,
      "instance":1,
      "accountid":369917733
   },
   "id":"2112720622",
   "message":"No need to accept, just testing out a bot.",
   "state":3,
   "itemsToGive":[  

   ],
   "itemsToReceive":[  
      {  
         "appid":730,
         "contextid":"2",
         "assetid":"10168993563",
         "classid":"1989300153",
         "instanceid":"302028390",
         "amount":1,
         "missing":true,
         "icon_url":"IzMF03bi9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdB2ozio1RrlIWFK3UfvMYB8UsvjiMXojflsZalyxSh31CIyHz2GZ-KuFpPsrTzBG0qe6yD3n-ZDLdYXKOTVxqTudcPGjZrGLx5ujCF2nASeh-EF9XdfEAo2JLNZiKahtv0oMVu2u_0UdyEhk6f9BKZAarxm1OMLh9m3IWGBD1M58",
         "icon_url_large":"IzMF03bi9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdB2ozio1RrlIWFK3UfvMYB8UsvjiMXojflsZalyxSh31CIyHz2GZ-KuFpPsrTzBG0qe6yD3n-ZDLdEC3YDlltU-cLND7c92Hxt-SVFGqfFe54SgACdfcFoDJPP82AOBtrhdZZ-Ga9zhwzDhgvNMZJfACpx2EfJbQ1xDhPJM5amiekAf1NktA",
         "icon_drag_url":"",
         "name":"Sealed Graffiti | Still Happy (Desert Amber)",
         "market_hash_name":"Sealed Graffiti | Still Happy (Desert Amber)",
         "market_name":"Sealed Graffiti | Still Happy (Desert Amber)",
         "name_color":"D2D2D2",
         "background_color":"",
         "type":"Base Grade Graffiti",
         "tradable":true,
         "marketable":true,
         "commodity":true,
         "market_tradable_restriction":7,
         "fraudwarnings":[  

         ],
         "descriptions":[  
            {  
               "type":"html",
               "value":"This is a sealed container of a graffiti pattern. Once this graffiti pattern is unsealed, it will provide you with enough charges to apply the graffiti pattern <b>50</b> times to the in-game world.",
               "app_data":""
            },
            {  
               "type":"html",
               "value":" ",
               "app_data":""
            },
            {  
               "type":"html",
               "value":"",
               "color":"00a000",
               "app_data":{  
                  "limited":"1"
               }
            }
         ],
         "owner_descriptions":[  

         ],
         "actions":[  
            {  
               "name":"Inspect in Game...",
               "link":"steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S%owner_steamid%A%assetid%D9253357711394385702"
            }
         ],
         "market_actions":{  
            "0":{  
               "name":"Inspect in Game...",
               "link":"steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D9253357711394385702"
            }
         },
         "tags":[  
            {  
               "internal_name":"CSGO_Type_Spray",
               "name":"Graffiti",
               "category":"Type",
               "category_name":"Type"
            },
            {  
               "internal_name":"normal",
               "name":"Normal",
               "category":"Quality",
               "category_name":"Category"
            },
            {  
               "internal_name":"Rarity_Common",
               "name":"Base Grade",
               "category":"Rarity",
               "color":"b0c3d9",
               "category_name":"Quality"
            },
            {  
               "internal_name":"Tint5",
               "name":"Desert Amber",
               "category":"SprayColorCategory",
               "category_name":"Graffiti Color"
            }
         ],
         "id":"10168993563",
         "owner_actions":[  

         ],
         "market_marketable_restriction":0
      }
   ],
   "isOurOffer":true,
   "created":"2017-05-13T09:50:24.000Z",
   "updated":"2017-05-13T09:50:48.000Z",
   "expires":"2017-05-27T09:50:24.000Z",
   "tradeID":"1915564581201455085",
   "fromRealTimeTrade":false,
   "confirmationMethod":0,
   "escrowEnds":null,
   "rawJson":"{\n\t\"tradeofferid\": \"2112720622\",\n\t\"accountid_other\": 369917733,\n\t\"message\": \"No need to accept, just testing out a bot.\",\n\t\"expiration_time\": 1495878624,\n\t\"trade_offer_state\": 3,\n\t\"items_to_receive\": [\n\t\t{\n\t\t\t\"appid\": \"730\",\n\t\t\t\"contextid\": \"2\",\n\t\t\t\"assetid\": \"10168993563\",\n\t\t\t\"classid\": \"1989300153\",\n\t\t\t\"instanceid\": \"302028390\",\n\t\t\t\"amount\": \"1\",\n\t\t\t\"missing\": true\n\t\t}\n\t],\n\t\"is_our_offer\": true,\n\t\"time_created\": 1494669024,\n\t\"time_updated\": 1494669048,\n\t\"tradeid\": \"1915564581201455085\",\n\t\"from_real_time_trade\": false,\n\t\"escrow_end_date\": 0,\n\t\"confirmation_method\": 0\n}"
}

I can easily get partner, id, message, state, isOurOffer and all the time things, but when I try to get itemsToRecieve, it just throws undefined

Why would it do that for only one of the objects?



via Frej Alexander Nielsen

No comments:

Post a Comment