-1
我有一个非常基本的问题。 我读尽管LibGDX文档各地关于JSON和谷歌的答案了几次,但它仍然简化版,工作..LibGDX解析标准JSON到一个对象
基本上我从像这样的服务器,可以作为拉动JSON:
{"id":1,"facebook_id":"23432232","json":"{\"json\":\"test\"}"}
我有这样一个类:
public class ServerJson
{
public static final String NAME = "ServerJson";
private int id;
private String facebookID;
private String json;
public ServerJson(){}
public ServerJson(int id, String facebookID, String json)
{
this.id = id;
this.facebookID = facebookID;
this.json = json;
}
public int getId() {
return id;
}
public String getFacebookID() {
return facebookID;
}
public String getJson() {
return json;
}
当我试图解析代码,这是行不通的。我得到null:
String resultString = httpResponse.getResultAsString(); //{"id":1,"facebook_id":"23432232","json":"{\"json\":\"test\"}"}
Json json = new Json();
ServerJson serverJson = json.fromJson(ServerJson.class, resultString);
log(serverJson.getFacebookID()); //<< Is null.
结果是什么结果字符串看起来像 – Barodapride
已更新,它与结果顶部相同。 –
你可以做serverJson.getId()工作吗? – Barodapride