2
列出
我已經轉換一個jsonArray到字符串:轉換jsonString通過GSON
[{"Key":"Comment","Value":"گواهی پایانکار با شماره ارجاع 2168439 صادر شد","Children":""},{"Key":"Version","Value":"BIZ.SC- Version=8.8.495.1","Children":""},{"Key":"lat","Value":"0","Children":""},{"Key":"lng","Value":"0","Children":""},{"Key":"District","Value":"11","Children":""},{"Key":"ScheduledMessage","Value":"{\"Id\":\"41b02583-1974-4f31-8ba1-c58d035f388b\",\"NotificationId\":\"53a23080-88cf-4256-855c-6ef2a51f2aab\",\"DistributionId\":\"98ee1d58-dd1e-4ef9-b82a-0af2a2a0e9ef\",\"CreationDateTime\":\"\\\/Date(1504277609736)\\\/\",\"ExpirationDateTime\":\"\\\/Date(4070908800000)\\\/\",\"Address\":\"Topics\/Notifications\/Global\",\"FileName\":\"\"}","Children":""}]
現在我想將其轉換通過GSON到POJO Java類作爲List<EventData>
List<EventData> result = GsonUtil.createGson().fromJson(eventArray,
new TypeToken<List<EventData>>() {}.getType());
notifyParcel.setEventData(result);
,這是我的POJO類:
public class EventData implements Serializable{
private List<Children> Children;
private String Key;
private String Value;
public List<Children> getChildren() {
return Children;
}
public void setChildren(List<Children> children) {
Children = children;
}
public String getKey() {
return Key;
}
public void setKey(String key) {
Key = key;
}
public String getValue() {
return Value;
}
public void setValue(String value) {
Value = value;
}
}
我去這個錯誤:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 2 path $
是什麼問題?
我改變它刪除
"Children": ""
:http://codepad.org/VDkjm3c4。但我得到了這個錯誤:'期望BEGIN_ARRAY,但是在第1行第87列路徑$ [0]。兒童''STRINGS' – sayres@sayres抱歉隊友,錯字:它應該是'[]'ae'「Children」:[]' http://www.jsoneditoronline.org/?id=fcab865350cf520e66fb7212dac7da94 –
老兄,這是我保存這個childlern的地方:http://codepad.org/Ab9ONuiP。我能做什麼?我不能[]沒有「」 – sayres