question

joshsagarold avatar image
joshsagarold Deactivated asked

Cloudscript JSON

From the referral example up on Github:

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?

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.");
		}
	}

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Seth Du avatar image
Seth Du answered

Yes, it is not contained in the SDK and our new solution is Plugin Manager. Please see the official repo on GitHub: https://github.com/PlayFab/UnitySDK/blob/master/PluginManager.md Also, you can refer to Andy’s answer in this thread: https://community.playfab.com/questions/24205/json-parsing-issues.html.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.