0

I currently have a JSON file with the following data:

   {
   "user":"me",
   "payment_method":"card",
   "items_bought":[
      {
         "id":"001",
         "name":"desk",
         "delivered":"false"
      },
      {
         "id":"455",
         "name":"chair",
         "delivered":"false"
      },
      {
         "id":"234",
         "name":"mouse pad",
         "delivered":"false"
      },
      {
         "id":"135",
         "name":"cabinet",
         "delivered":"false"
      }
   ]
}

I wanna parse through the "items_bought" so i could get the name of each item in the array.

I am currently using this code to read my JSON file. I just need help for the loop so i could get the member or the array.

jsonString = File.ReadAllText(Application.dataPath + "/account_response.json");
jsonMessage = JsonMapper.ToObject(jsonString);
Debug.Log(jsonMessage["user"].ToString()); //prints value of user
Debug.Log(jsonMessage["payment_method"].ToString()); //prints value of payment_method

Any heads up would be much appreciated. Thanks.

zoenightshade
  • 159
  • 2
  • 12

0 Answers0