how i can get fields name from Xojo.Core.Dictionary

I need to get fields name from the dict to validate it
Dim dict As Xojo.Core.Dictionary = Xojo.Data.ParseJSON( Xojo.Core.TextEncoding.UTF8.ConvertDataToText( Content ) )


but like this dict.value(“fieldName”) or dict.value(fieldName)

i try like dict.value(“fieldName”) and i have error

The key will be a string, so whether you provide it in a variable, static, or constant is up to you. But it’s case-sensitive so the key “aaa” will not match the key “Aaa”, for example, and both could exist in your JSON.

i have error KeyNotFoundException

If HTTPStatus = 200 Then
Dim ff As Integer
Dim hh As Text
Dim jsonData As Text = Xojo.Core.TextEncoding.UTF8.ConvertDataToText(content)
dim d as Xojo.Core.Dictionary = Xojo.Data.ParseJSON( jsonData)

//dim msg as new iOSMessageBox
//msg.Buttons = Array("OK")
//msg.Title = "Info"
//msg.Message = Xojo.Core.TextEncoding.UTF8.ConvertDataToText( Content ) 

// to fill listbox

Dim dict As Xojo.Core.Dictionary = Xojo.Data.ParseJSON( Xojo.Core.TextEncoding.UTF8.ConvertDataToText( Content ) )

If (dict.Count >=2)  Then
    hh=d.value("DataSocioNum")   <<<<<< I need to see what is the fields names
  Catch e As KeyNotFoundException
  End Try
End If

// Process content for error
App.mQueryURL = “”

dim msg as new iOSMessageBox
msg.Buttons = Array("OK")
msg.Title = "Error"
msg.Message = Xojo.Core.TextEncoding.UTF8.ConvertDataToText( Content )

End If

End Sub

This is easier with the classic Dictionary. Any reason you chose to use the Xojo framework?


dim keys() as string
for each entry as Xojo.Core.DictionaryEntry in myDict
  keys.Append entry.Key
// Now the keys are in that array

In your code, you are checking the key in d, not dict, is that what you intended?

(I recommend using descriptive names for your variables. It’s more typing, but makes for easier-to-read code.)

Finally, when posting code, please help us out by using the Code tags.

No reason i was thinking the xojo.core is more new, So what is the deferences in classic vs Xojo framework ?


The Xojo framework has been de-emphasized. The new version of Xojo has ParseJSON to a Dictionary built in.

but i am using this code in IOS

Moved to iOS channel.