【发布时间】:2014-06-04 13:56:51
【问题描述】:
您好,我有以下 json 数据
{
"actionslist": [
{
"type": "SET_TP_DST",
"port": 135
},
{
"type": "OUTPUT",
"port": {
"node": {
"id": "00:00:00:00:00:00:00:03",
"type": "OF"
},
"id": "2",
"type": "OF"
}
}
]
}
我想使用gson.fromJson 反序列化这个 json。但这里的问题是port 有时包含一个数字,有时包含一个对象。如何获取port 来获取对象和数字?
【问题讨论】:
-
这取决于
type?你可以编写自己的反序列化器
标签: json deserialization gson