如何在 Android 中阅读复杂的 JSON
How to read complex JSON in Android
如果我有这个字符串:
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 ; }; }; }; }
如何在 Android 列表视图中显示它?
预期输出为:
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
使用数组,您可以将数据放在列表视图中。
希望这会有所帮助:)
如果我有这个字符串:
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 ; }; }; }; }
如何在 Android 列表视图中显示它?
预期输出为:
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
使用数组,您可以将数据放在列表视图中。 希望这会有所帮助:)