[英]Unity Json Deserialization
From the referral example up on Github: GithubLink 从Github上的推荐示例: GithubLink
The PlayFab.Json.JsonWrapper doesn't seem to be in the SDK anymore, how can I use the Unity JSON system to deserialize the list? PlayFab.Json.JsonWrapper似乎不再出现在SDK中,我如何使用Unity JSON系统反序列化列表?
Thanks 谢谢
void OnRedeemReferralCodeCallback(ExecuteCloudScriptResult result)
{
// output any errors that happend within cloud script
if(result.Error != null)
{
Debug.LogError(string.Format("{0} -- {1}", result.Error, result.Error.Message));
return;
}
List<ItemInstance> grantedItems = PlayFab.Json.JsonWrapper.DeserializeObject<List<ItemInstance>>(result.FunctionResult.ToString());
if(grantedItems != null)
{
Debug.Log("SUCCESS!...\nYou Just Recieved:");
string output = string.Empty;
foreach(var itemInstance in grantedItems)
{
output += string.Format("\t {0} \n", itemInstance.DisplayName);
}
this.inventory.AddRange(grantedItems);
SearchForReferralBadge();
ShowReferredGroup();
Debug.Log(output);
foreach(var statement in result.Logs)
{
Debug.Log(statement.Message);
}
}
else
{
Debug.LogError("An error occured when attemtpting to deserialize the granted items.");
}
}
Take a look to my answer here: Converting arrays of arrays to json 看看我的答案: 将数组数组转换为json
Final EDIT part. 最终编辑部分。
You should be able to understand how Unity actually works with json serialization (I made a really simple example there). 你应该能够理解Unity实际上如何使用json序列化(我在那里做了一个非常简单的例子)。
To make your question more clear you should try to also make an example of json you need to deserialize. 为了使您的问题更加清晰,您应该尝试以json为例进行反序列化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.