NJDude Expert Licensed User Longtime User Jun 17, 2011 #1 I'm having a little bit of difficulty with B4A and JSON. I have a simple MySQL database and each record contains 3 fields: Name, Age and Sex The result in JSON format is: {"Name":"Joel","Age":"20","Sex":"M"} My problem is, I've been unable to figure out how to parse it, I've read the examples posted but, I think I'm having a bad day Thanks in advance. Last edited: Jun 17, 2011
I'm having a little bit of difficulty with B4A and JSON. I have a simple MySQL database and each record contains 3 fields: Name, Age and Sex The result in JSON format is: {"Name":"Joel","Age":"20","Sex":"M"} My problem is, I've been unable to figure out how to parse it, I've read the examples posted but, I think I'm having a bad day Thanks in advance.
Erel B4X founder Staff member Licensed User Longtime User Jun 17, 2011 #2 Have you read the JSON tutorial: http://www.b4x.com/forum/basic4andr...als/6923-android-json-tutorial.html#post39966 Please post your parsing code and the error that you are getting. Upvote 0
Have you read the JSON tutorial: http://www.b4x.com/forum/basic4andr...als/6923-android-json-tutorial.html#post39966 Please post your parsing code and the error that you are getting.
NJDude Expert Licensed User Longtime User Jun 17, 2011 #3 Yes, I've read that tutorial but that example has sub items, mine is just a flat or single structure, I'm not sure exactly how to read them using JSON. Upvote 0
Yes, I've read that tutorial but that example has sub items, mine is just a flat or single structure, I'm not sure exactly how to read them using JSON.
dealsmonkey Active Member Licensed User Longtime User Jun 17, 2011 #4 NJDude said: Yes, I've read that tutorial but that example has sub items, mine is just a flat or single structure, I'm not sure exactly how to read them using JSON. Click to expand... Give me a short while and I'll post an example,. Upvote 0
NJDude said: Yes, I've read that tutorial but that example has sub items, mine is just a flat or single structure, I'm not sure exactly how to read them using JSON. Click to expand... Give me a short while and I'll post an example,.
Erel B4X founder Staff member Licensed User Longtime User Jun 18, 2011 #5 Code: Copy Dim JSON As JSONParser JSON.Initialize(jsonstring) Dim m As Map m = JSON.NextObject Msgbox(m.get("Name"), "") Upvote 0
Code: Copy Dim JSON As JSONParser JSON.Initialize(jsonstring) Dim m As Map m = JSON.NextObject Msgbox(m.get("Name"), "")
NJDude Expert Licensed User Longtime User Jun 18, 2011 #6 Thanks, I was adding an extra MAP, now I see how it works. Upvote 0