I have used this site for years, but have never published. I'm at a standstill and hope someone can help me.
I use very similar code for Slicekick to send a data-free JSON syntax application here, but it may not seem like it understands this JSON file. I edited its JSON information to reflect the exact format I'm trying to parse to save space / time. How to parse "Results" so that I can query for "Name" and "Type"? Like his problem with Similar and Info, how to parse the Info and Results in the file below?
Here is an example JSON file edited in the exact format I use:
{ "head": { "title": "Music", "status": "200" }, "Info": [ { "Name": "Mos Def", "Type": "music", "Results": [ { "Name": "Talib Kweli", "Type": "music" }, { "Name": "Black Star", "Type": "music" }, { "Name": "Little Brother", "Type": "music" } ] }, { "Name": "Mos Def", "Type": "Vehicles", "Results": [ { "Name": "Chevy", "Type": "Car" }, { "Name": "Ford", "Type": "Car" }, { "Name": "Pontiac", "Type": "Car" } ] } ] }
Part of my code that might be of interest:
... I am doing an httpget ... which is built into StringBuilder ... creates a JSONObject with StringBuilder results
jArray = new JSONObject(result);
... then returns that
Then on ...
JSONArray Info = json.optJSONArray("Info"); System.out.println("HERE IS INFO: "); System.out.println(Info);
And mostly here, where I'm at a standstill. I put printed messages to try to narrow down the problem.
Parsing "Info" allows me to search for: "Name": "Mos Def" "Type": "music" -and- "Name": "Mos Def" "Type": "Vehicles"
Replacing the search "Info" with "Results" does not give me any data. (Not found)
Any ideas?