Load Json and display value

Hello
I’m pretty new to Xojo and fail on simple things. I would like to display a value of a Json object:

[code]Var nameList As String = “[{”“name”": ““john””}]"

Dim allNames As New JSONItem
allNames.Load(nameList)

MessageBox( allNames.Value(“name”) )[/code]

On executing this code it jumps into the Debugger without telling me whats wrong. The visual bug sticks to the MessageBox (last line). What do I have to do to display the name “john” of JSon object with key “name”?

Further tries to access the value (john) of key “name”, all with errors:

MessageBox( allNames(“name”) )
MessageBox( allNames[“name”].Value )
MessageBox( allNames(“name”).Value )

Also tried to load a Json structure into Dictionary (what I want in the end) but fails as well, no error message:

Var nameList As String = “{ ““person”” : { ““name””: ““John”” } }”

Dim opCodes As Dictionary = Xojo.Data.ParseJSON(nameList.ToText)

Use: MessageBox( allNames.Child(0).Value(“name” ))

By putting “nameList” in [] you have created an array… with 1 element.

Your JSON string is not an object, it’s an array whose first item is an object.

Darn it, Jim.

Thank you guys, very helpful! You’re right! I copied the JSON sample from a Xojo page and was confused why Xojo uses Array brackets. Dunno if I can accept both ansers, otherwise: first come, first serve. I now can accesss it (no need of embracing by Array brackets)