How can I use JSON objects more than once?

This is hard for me to explain so let me just give you all an example.

Say you’re creating a game and you want store information about of list of skills such as: blacksmithing, carpentry, etc… Then you have a list of items that can be made pertaining to the skills: copper dagger, wood plank, etc.. And each of those items have several different ingredients which contain other information such as quantity.

How would you go about storing this information using JSON in neat format considering that some items may have the same ingredients?

{"skill":[
  "blacksmithing":{
     "items":[
       {"copper dagger":{
         "ingredients":[] // this where i get lost because i feel like its too complicated after this point
       }},
       // and so on
      ]
   },
  "carpentry":{
     "items":[]
  }
]}

I’ve never really created any JSON files myself so I’m not sure if I’m doing this right. I don’t even know if JSON is the correct way to approach this.. I’m just trying to create an iOS application and a web application that would read this information in, parse it, and create the objects accordingly.


Source: oop

Leave a Reply