我有一個JSON:GSON反序列化
"account_representatives": [
{
"Sales Person": 1307,
"default_ticket_assignments": [
""
],
"Primary Account Manager": 1307,
"Secondary Support-3": 1151,
"Relationship Mgr": 1307,
"authorized_resources": [
""
],
"Technical Account Manager": 164
}
]
,我有一個類,它的結構是這樣的:
public class AccountRepresentative {
@SerializedName("authorized_resources")
@Expose
private List<String> authorizedResources = new ArrayList<String>();
@SerializedName("default_ticket_assignments")
@Expose
private List<String> defaultTicketAssignments = new ArrayList<String>();
@Expose
private Map<String, String> repFields;
/**
* @return The authorizedResources
*/
public List<String> getAuthorizedResources() {
return authorizedResources;
}
/**
* @param authorizedResources The authorized_resources
*/
public void setAuthorizedResources(List<String> authorizedResources) {
this.authorizedResources = authorizedResources;
}
/**
* @return The defaultTicketAssignments
*/
public List<String> getDefaultTicketAssignments() {
return defaultTicketAssignments;
}
/**
* @param defaultTicketAssignments The default_ticket_assignments
*/
public void setDefaultTicketAssignments(List<String> defaultTicketAssignments) {
this.defaultTicketAssignments = defaultTicketAssignments;
}
/**
*
* @return the dynamic jsonObjects
*/
public Map<String, String> getRepFields() {
return repFields;
}
/**
* @param repFields The repFields
*/
public void setRepFields(Map<String, String> repFields) {
this.repFields = repFields;
}
}
我使用GSON結合這些,我能夠綁定2 JsonArrays。
我也可以W/O的jsonArrays使用How can I convert JSON to a HashMap using Gson?,
但在這種情況下,反序列化的動態性能,我不知道怎麼弄的動態特性, 我的計劃據說是把動態特性爲hashmap,但2 jsonArrays的方式。
感謝您的幫助,
你的意思是比如說,你不確定'鍵值對'的關鍵?它可以改變,恕不另行通知? –
是的..鑰匙是動態的,所以我不能在飛行中抓住他們 – Keiichi