my PHP file generate list of players like this :
["EnzoDeg40","EDeg40","AstroGeek"]
I have successfully downloaded the content with Unity Web Request. But I can't seem to find a solution to convert JSON to a simple array.
my PHP file generate list of players like this :
["EnzoDeg40","EDeg40","AstroGeek"]
I have successfully downloaded the content with Unity Web Request. But I can't seem to find a solution to convert JSON to a simple array.
You can use the JsonUtility. Note that "Unity does not support passing other types directly to the API, such as primitive types or arrays. If you need to convert those, wrap them in a class or struct of some sort.". You have to do something like this:
[Serializable]
public struct StringArrayWrapper { public string[] items; }
private Start()
{
var arry = JsonUtility.FromJson<StringArrayWrapper>("{\"items\":[\"EnzoDeg40\",\"EDeg40\",\"AstroGeek\"]}")