我有一個JSON字符串是這樣的: http://pastebin.com/ckUZadwL如何解析這些json字符串? (使用GSON)
我試圖用GSON解析他們。但是,我有一個問題。在新的響應中,user元素包含通用id作爲鍵,並且由於它在內部類中,所以我不確定如何解析它。
謝謝你的幫助。
這裏有幾個類容器我建立並存儲在那裏的數據:
public class CometCallback
{
public int new_offset;
public Data[] data;
}
public class Data
{
public long plurk_id;
public int response_count;
public Response response;
public UserInfo user;
public String type;
public Plurk plurk;
}
public class Response
{
public String lang;
public String content_raw;
public long user_id;
public String qualifier;
public long plurk_id;
public String content;
public long id;
public String posted;
}
public class Plurk extends Response
{
public Object[] replurkers;
public int responses_seen;
public int replurkers_count;
public String replurker_id;
public int response_count;
public boolean replurkable;
public Object limited_to;
public int favorite_count;
public int is_unread;
public Object[] favorers;
public int plurk_type;
public boolean replurked;
public boolean favorite;
public int no_comments;
public long owner_id;
}
謝謝你的建議,我有幾件事情來嘗試現在:) – Patrick 2012-02-06 14:31:02
感謝您的信息。我似乎能夠提取我想要的價值!我需要進一步測試以瞭解「enableComplexMapKeySerialization」的功能。 – Patrick 2012-02-07 17:43:11
嗡嗡聲...似乎它仍然會反序列化爲Map對象,即使沒有啓用ComplexMapKeySerialization。我猜Map不是一個複雜的關鍵,但很高興知道我可以在將來像這樣解析複雜關鍵字! –
Patrick
2012-02-08 05:55:28