【发布时间】:2015-08-11 08:02:55
【问题描述】:
我正在使用 Unity C#,并希望从我的推送通知发送的嵌套 json 对象中检索数据。
json 对象如下所示:
{
"aps":
{
"badge":1
,"sound":"default.mp3"
,"alert":"test my push"
}
,"u":"{\"custom\":\"{\"gameid\":\"12345\"}\"}
}
我像这样检索 json:
string payload = aboveJsonString;
Hashtable table = (Hashtable)easy.JSON.JsonDecode(payload);
Hashtable data = (Hashtable)easy.JSON.JsonDecode(table["u"].ToString());
Hashtable gamejson =(Hashtable)easy.JSON.JsonDecode(data["custom"].ToString());
在 gamejson 之前一切正常?
data["custom"] prints {"gameid":"12345"}
gamejson["gameid"] prints nothing?!?
我有点迷失了。任何人都可以帮我解决这个问题,我们将不胜感激。
提前致谢:-)
【问题讨论】:
-
您的 json 无效...
-
你能解释一下吗?
-
这有效吗?
"u":"{\"custom\":\"{\"gameid\":\"12345\"}\"} -
好吧,我确实从“u”和“custom”中得到了正确的结果。它只是最后一个没有的Hashtable gamejson?!
-
@Mansa jsonlint.com