InvalidCastException When Deployed to Hololens (but runs fine in Unity)

I created a testing app to visualize some JSON data. It ran fine in Unity without error, but when deployed to Hololens it gave me the following error:

“InvalidCastException: Unable to cast object of type 'Wrapper’1[p0] to type ‘UnityEngine.IUnitySerializable’.”

The “Wrapper” and “p0” are two classes I created to parse JSON. I suspect there might be something wrong in the way I wrote them, but couldn’t understand why Unity won’t show the error. Attach is the code:

public class CFD_JSON : MonoBehaviour
{
    private List<p0> cfd = new List<p0>();                                     

    IEnumerator Start()
    {
        string url = "http://140.247.162.185:9000/point";
        WWW www = new WWW(url);
        yield return www;

        if (www.error != null)
        {
            Debug.Log("error");
        }
        else
        {
            cfd = ArrayJson.getJsonArray<p0>(www.text);
           ...*some actions*
        }
    }
}

...

[System.Serializable]
public class ArrayJson
{
    public static List<p0> getJsonArray<T>(string json)
    {
        string newJson = "{ \"array\": " + json + "}";                          
        Wrapper<p0> wrapper = JsonUtility.FromJson<Wrapper<p0>>(newJson);
        return wrapper.array;
       }

    [System.Serializable]
    private class Wrapper<p0>
    {
        public List<p0> array = new List<p0>();
    }
}

[System.Serializable]                                                       
public struct p0
{
    public float x;
    public float y;
    public float z;
    public float vmeg;
    public float vx;
    public float vy;
    public float vz;
}

Many thanks!

I have the exact same issue when I tried to wrap a JSON string in HoloLens…

Hello

You have to use the dll Newtonsoft (inlcued in Holotoolkit).

import Newtonsoft;

...

MyClass data = Newtonsoft.Json.JsonConvert.DeserializeObject<MyClass>(jsonString);