Sina Weibo has some of the JSON data as follows, you will find that this is a number of groups, but the array does not have a key, the object in the array also has no key. How to resolve it? Fastjson encounters this nameless array set nameless objects also report an exception. It is therefore recommended that native JSON parsing be used.
First, the question:
Second, the Analytic code:
Com.ht.weibo.weibomodel;
Com.sina.weibo.sdk.openapi.models.Status;
Org.json.JSONArray;
Org.json.JSONException; Org.json.JSONObject; Java.util.ArrayList;
{
arraylist<status> statuses;
Arraylist<status> () {
statuses;
}
(arraylist<status> statuses) {
. statuses = statuses;
(String json) {
(JSON!=) {
{
Jsonarray array = Jsonarray (JSON);
statuses = arraylist<> ();
(i =; I < Array.Length (); i++) {
Jsonobject jsonobject = Array.getjsono Bject (i);
Status Status = Status.parse (Jsonobject);
Statuses.add (status);
}
}
(Jsonexception e) {
E.printstacktrace ();
}
}
}
For the other solution of this problem, specific reference: (not practice)
Http://zm8.sm-img2.com/?src=http%3A%2F%2Fsegmentfault.com%2Fq%2F1010000000174990&uid= 0b4cd023903934907ec4a15ea96326f5&hid=29ae2ef764df9a92491d377a505210ed&pos=1&cid=9&time= 1433608784138&from=click&restype=1&pagetype=0000004000000402&bu=web&query=json%e8%a
How do I get the key value of the JSON data dynamic change?
Http://www.apkbus.com/android-114271-1-1.html
There is a Jsonobject.keys () method. The return value is the iterator
Iterator<string> = json. ();
Because there is only one object, you do not have to do more in-depth iterations
Four
JSON parsing, if some of the fields or objects are opt, then you need to do an empty judgment