简体   繁体   中英

How to read complex JSON in Android

If I have this string:

anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=anyType{complexType=anyType{sequence=anyType{element=anyType{}; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; }; }; }; }; }; }; }; diffgram=anyType{DocumentElement=anyType{mytable=anyType{USER_ID=83; PROJECT_BY_DETAILS=An adaptation of a nursery rhyme into a dramatic film; }; mytable=anyType{USER_ID=88; PROJECT_BY_DETAILS=Test - over ye mountain blue ; }; }; }; }

How can I display it in an Android list view?

The expected output is:

USER_ID=83
PROJECT_BY_DETAILS=An adaptation of a nursery rhyme into a dramatic film

USER_ID=88
PROJECT_BY_DETAILS=Test - over ye mountain blue
String [] out;
Int i = 0;
//String result is your output (the code part from your question)
While(Result.indexOf("USER_ID") != -1){
Result = Result.substring(Result.indexOf ("USER_ID"),Result.length());
out[i] =  Result.substring(0,Result.indexOf(";");
Result = Result.substring(Result.indexOf (";"), Result.length());
i++;
}
//out [] is your array with the data you want to have

And with the array you can put the data in a listview. Hope this helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM