question

yogev avatar image
yogev asked

How to send list of strings from azure to unity

I am sending a list of strings from Azure to Unity but cannot receive it. If I use cast type it won't work how can I convert the result to a list?

If I put result.FunctionResult in a debug I see only one of the strings that are inside

CloudScript
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

·
Gosen Gao avatar image
Gosen Gao answered

I think you mean how to return a list of strings from an Azure Function to the caller(Unity). If you cannot see the expected content in the function result, please re-check your Azure Function to see if the original content is correct. As for result handling, Unity SDK uses SimpleJson to parse JSON. If AF returns a list, SimpleJson will parse it into JsonArray by default, you can refer to the code below.

What I return in Azure Function:

 var ret = new List<string>();
 ret.Add("V1");
 ret.Add("V2");
 ret.Add("V3");
 return ret;

Handling in Unity:

 var list = result.FunctionResult as PlayFab.Json.JsonArray;
 foreach (var item in list)
 {
     Debug.Log(item);
 }
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.