我有一个从PHP文件发送到Unity的项目列表WWW.
的WWW.text样子:
[
{
"playerId": "1",
"playerLoc": "Powai"
},
{
"playerId": "2",
"playerLoc": "Andheri"
},
{
"playerId": "3",
"playerLoc": "Churchgate"
}
]
Run Code Online (Sandbox Code Playgroud)
我[]从哪里修剪额外的string.当我尝试使用它解析它时Boomlagoon.JSON,只检索第一个对象.我发现我已经到deserialize()了列表并导入了MiniJSON.
但我很困惑如何deserialize()这个列表.我想遍历每个JSON对象并检索数据.如何使用C#在Unity中执行此操作?
我正在使用的课程是
public class player
{
public string playerId { get; set; }
public string playerLoc { get; set; }
public string playerNick { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
修剪后[]我可以使用MiniJSON解析json.但它只返回第一个KeyValuePair.
IDictionary<string, object> players = Json.Deserialize(serviceData) as IDictionary<string, object>;
foreach (KeyValuePair<string, …Run Code Online (Sandbox Code Playgroud)