[英]How to parse JSON Response Object and display it in TextView
I have a URL and i am trying to POST JSON data to that URL and this URL will return a RESPONSE OBJECT and how to read that JSON and display it in TextView
嘗試使用 VOLLEY 解析 JSON
{ "isSuccess":true, "returnCode":"SUCCESS", "returnMessage":"Success", "resource":null, "errors":null }
VOLLEY JSON 解析技術對此有用嗎?
雖然我沒有用過凌空,但它可以在 Java 中工作。 首先,為了方便序列化,使用 DTO。
public class MyRespone extends Serializable {
private Boolean isSuccess;
private String returnCode;
private String returnMessage;
private String resource;
private String errors;
//getters and setters here
}
然后你可以使用 Gson/Jackson/FastJSON/Volley 來解析 RESPONSE OBJECT。
//Gson
Gson gson = new Gson();
MyResponse myResponse = gson.parseObject(RESPONSE_OBJECT_STR, MyResponse.class);
//jackson
ObjectMapper mapper = new ObjectMapper();
MyResponse myResponse = mapper.readValue(RESPONSE_OBJECT_STR,MyResponse.class);
你可以找到凌空版本來解決你的問題。 http://www.androiddeft.com/json-parsing-android-volley/
希望這會有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.