{"errors":{"options":["is invalid"],"name":["can't be blank"]}}
[code]Dim jsonData As Text
jsonData = Xojo.Core.TextEncoding.UTF8.ConvertDataToText(data)
Dim jsonDict As Xojo.Core.Dictionary
jsonDict = Xojo.Data.ParseJSON(jsonData)
For Each entry As Xojo.Core.DictionaryEntry In errorsDict
Window1.txtSummary.Text = Window1.txtSummary.Text + " " + entry.Key + " " + entry.Value
Next[/code]
I get a type mismatch on the entry.value expecting text but getting Auto(0)
You skipped a line here assigning errorsDict, but no matter, I get the gist. But the error is correct, you are attempting to assign an Auto array like ["is invalid"] to text.
You need to look at the braces and brackets. You have a dictionary containing one entry “errors”, where the value is a dictionary containing two entries “options” and “name”, where each of the values is an array of strings:
[code]Dim jsonData As Text = “{”“errors”":{"“options”":["“is invalid”"],"“name”":["“can’t be blank”"]}}"
Dim jsonDict As Xojo.Core.Dictionary = Xojo.Data.ParseJSON(jsonData)
For Each errorsEntry As Xojo.Core.DictionaryEntry In jsonDict // “errors”
Dim errorsValue As Xojo.Core.Dictionary = errorsEntry.Value
For Each errorEntry As Xojo.Core.DictionaryEntry In errorsValue // “options” & “name”
Dim errorKey As Text = errorEntry.Key
Dim errorValues() As Auto = errorEntry.Value // first time array with values of “options” and
// second time array with values of “name”
Dim errorValue As Text = errorValues(0)
MsgBox errorKey + " " + errorValue
Next
Next[/code]
For Each errorsEntry As Xojo.Core.DictionaryEntry In jsonDict
For Each errorEntry As Xojo.Core.DictionaryEntry In Xojo.Core.Dictionary(errorsEntry.Value)
Dim errorValues() As Auto = errorEntry.Value
MsgBox errorEntry.Key + " " + errorValues(0)
Next
Next