Android Question List entries in a JSON string

Martincg

Member
Licensed User
Longtime User
If read arrays of JSON strings like this
{
"value":17,
"date":"2019-09-29 20:30:00"
}

Not all will have both entries.
How do I find out which entries are included?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are several mistakes in this code:
1. The case is important. It should be MyMap.Get("value")
2. If you are interested in a specific key and you are not sure whether it exists or not then you should check it with ContainsKey:
B4X:
If MyMap.ContainsKey("value") Then
 Dim value As Int = MyMap.Get("value")
End If
Another option if you want to be more sophisticated:
B4X:
newVal = MyMap.GetDefault("value", newVal)
 
Last edited:
Upvote 0

Martincg

Member
Licensed User
Longtime User
Thanks Erel, I will use your suggestions.
I probably should have found that myself, but although I did one project a few years ago I am really a newbie and I can only take in so much at a time.
 
Upvote 0
Top