Skip to content

Instantly share code, notes, and snippets.

@q8f13
Created November 27, 2018 09:14
Show Gist options
  • Save q8f13/1a967c7a7485004241400da27a6a8edf to your computer and use it in GitHub Desktop.
Save q8f13/1a967c7a7485004241400da27a6a8edf to your computer and use it in GitHub Desktop.
add json array support to unity
public class JsonHelper
{
public static T[] getJsonArray<T>(string json)
{
string newJson = "{ \"array\": " + json + "}";
Wrapper<T> wrapper = UnityEngine.JsonUtility.FromJson<Wrapper<T>>(newJson);
return wrapper.array;
}
[System.Serializable]
private class Wrapper<T>
{
public T[] array;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment