-1
解析特殊鍵JSON這是JSON字符串:如何GSON
{
new : "",
xx : "yy",
......
}
Java中,關鍵new
,
private String new;
是非法的。
如何編寫我的域類?
解析特殊鍵JSON這是JSON字符串:如何GSON
{
new : "",
xx : "yy",
......
}
Java中,關鍵new
,
private String new;
是非法的。
如何編寫我的域類?
如何編寫我的域類?
由於new
是java中的關鍵字,因此您不能將其用作變量名稱。您可以使用標註SerializedName
來表示該成員應該序列化爲JSON,並提供提供的名稱值作爲其字段名稱。
示例域類:
class NewDetail{
@SerializedName(value="new")
private String newValue;
private String xx;
// getter & setter
}
謝謝!你是對的 –
http://stackoverflow.com/questions/6796662/using-gson-to-parse-a-json-with-dynamic-key-and-value-in- android請參考這個 –
這不是有效的JSON。去json.org學習語法 - 學習只需要5-10分鐘。 –
這個JSON來自服務器,我什麼也做不了。我需要解析它。 –