我有一个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