java - JSON parsing Issues Redux -
I had problems in the past with parsing my JSON code, and I almost had this and lost all my code changes I was giving it the courage of my JSON (which I have verified that it gets cured). It's just parsed ... I want to get the "full text" field and I think it has been inserted into an array ...
try {BufferedReader reader = new BufferedReader ( New InputStreamReader inputstream, "UTF-8"), 8); Stringbilder sb = new stringbiller (); String line; While ((line = reader. Readline ())! = Null) sb.append (row + "\ n"); Result = sb.toString (); } Hold (exception e) {Log.e ("log_tag", "Error converting result" + e.toString ()); } {JSONObject rootobject = try new JSONObject (results) .getJSONObject ("query"). GetJSONObject ("Result"); } Hold (JasonAxception E) {Log.e ("Jason Parser", log .getStackTraceString (e)); E.printStackTrace (); } Return tap; Within this, I agree that the JSONObject area is wrong. I should get the "complete" value on all JSON objects and eventually put them in the database. I am underlining the team names from this website.
In my mind, I should be able to use
string teamname = Rootbizject .getString ("full text"); In some way I have tried this, but it does not work at all. Actually I get an error message "No value for integer" when I see error log.
I know I'm going wrong somewhere but it can not be enough. I'm still confused with JSON parsing and whatnot, but I'm determined to get there.
This sample is a link to JSON (the URL I am using)
http://bit.ly/1JnlSck Sorry for forgetting it in the first post.
What you should do, your JSON should be restructured. Currently you have this ...
"Result": {"Team: \" Unilaglestin die \ "": {"Printout": [], "Full text": " Team: \ "UnglaLifen die \", "Fullural": "http://wiki.planetkubb.com/wiki/Team:%22Die_Unglaublichen%22", "Namespace": 822, "exists": true}, "team : "Lech Kubbs Bricks": {"Printouts": [], "Fulltext": "Team: (Can not Stand) Le Cubby Bricks", "Fullural": "http://wiki.planetkubb.com / Wiki / Team: (% 27t_Stand) _Le_Kubb_Bricks "," namespace ": 822," present ": true}} ... where" results " JSONObject is JSONObject in which there are many children JSONObjects. If you can do it again, then the "result" is a JSONArray which contains JSONObjects, such as ...
"Result": [ {"Team": "Unglaublichen Die", "Printouts": [], "Full Text": "Team: \" Die Unglaublichen \ "," fullurl ":" http://wiki.planetkubb.com/wiki/ Team:% 22Die_Unglaublichen% 22 "," Namespace ": 822," "Team: (Can not stand) Kube Bricks", "Fullerle", "Integer": "True"}, "Team": " Can not be) Le cub bricks "," printouts ": []," fulltext "": "Http://wiki.planetkubb.com/wiki/Team:(Can%27t_Stan D) _Le_Kubb_Bricks "," namespace ": 822," exists ": true is]] . .. then you can loop through the "results" array and you can get each of your JSONObjects and any names / values:
try {JSONArray resultsArray = rootObject.getJSONArray ("result"); For (int i = 0; i & lt; resultsArray.length (); i ++) {JSONObject teamObject = resultsArray.getJSONObject (i); String fulltext = teamObject.getString ("full text"); }} Hold (JasonX Express E) {e.printStackTrace (); }
Comments
Post a Comment