My deserializer class is as follows
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class PlayerHandler
{
public int id;
public Vector2 allposition;
public Quaternion allrotation;
public Vector2 allscale;
public Vector3 linepos0;
public Vector3 linepos1;
public int movetype;
public PlayerHandler(int ids,Vector2 allpos,Quaternion allrot,Vector2 allscal,Vector3 Line0,Vector3 Line1,int Moves)
{
this.id = ids;
this.allposition = allpos;
this.allrotation = allrot;
this.allscale = allscal;
this.linepos0 = Line0;
this.linepos1 = Line1;
this.movetype = Moves;
}
}
[System.Serializable]
public class PlayerMovement
{
public int movenumber;
public string notemsg;
public PlayerMovement(int Movenum,string Note)
{
this.movenumber = Movenum;
this.notemsg = Note;
}
}
[System.Serializable]
public class RootObject
{
public PlayerHandler[] datas;
}
Using this class in the below code but not getting any output.Getting this error
"ArgumentException: JSON must represent an object type.
UnityEngine.JsonUtility.FromJson (System.String json, System.Type type) "
If I could not solve with JSON utility(since multiple arrays) I have added SIMPLE JSON to the project.How to retrieve data using Simple JSON.
using (FileStream fs = new FileStream(Application.persistentDataPath + "/" + filename, FileMode.Open))
{
BinaryReader filereader = new BinaryReader(fs);
jsonLoadstring = filereader.ReadString();
fs.Close();
Debug.Log("JsonLoaded String==" + jsonLoadstring);
var deserialize = JsonUtility.FromJson<RootObject>(jsonLoadstring);
Debug.Log("Deserialized data = "+deserialize.datas);
}