繁体   English   中英

如何解析 JSON 响应 Object 并在 TextView 中显示

[英]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.

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