Given a block of JSON such as below,
{
"word": "dog",
"definitions": [
{
"definition": "a smooth-textured sausage of minced beef or pork usually smoked; often served on a bread roll",
"partOfSpeech": "noun"
},
{
"definition": "go after with the intent to catch",
"partOfSpeech": "verb"
}
]
}
I know how use Unity's built in JsonUtility to create a class to parse a string...
WORDCLASS json = WORDCLASS.CreateFromJSON(someJSONstring);
print(json.word);
Example class for JsonUtility
[System.Serializable]
public class WORDCLASS
{
public string word;
public static WordJSON CreateFromJSON(string jsonString)
{
return JsonUtility.FromJson<WordJSON>(jsonString);
}
}
I understand that "definitions" is an array of Dictionaries (with keys "definition" and "partOfSpeech" ... I just don't understand the correct way to get to them... (i.e. I would like to loop through and print out all the definitions in the array...
Although I'm attempting to use the built in Unity JsonUtility, I am open to other (more efficient) approaches such as Newton Json...
Thanks for your time helping out.