hi. firstly sorry for my english
im trying to convert this structure into json with unity jsonUtility:
[Serializable]
public class MainJson
{
public int x;
public List<Detail> detail = new List<Detail>();
public List<type2> type2 = new List<type2>();
public MainJson()
{
x = 10;
detail.Add(new type1());
detail.Add(new type2());
type2.Add(new type2());
}
}
[Serializable]
public class Detail
{
}
[Serializable]
public class type1 : Detail
{
public int t1;
public type1()
{
t1 = 1;
}
}
[Serializable]
public class type2 : Detail
{
public int t2 = 2;
public type2()
{
t2 = 1;
}
}
but the output is :
{"x":10,"detail":[{},{}],"type2":[{"t2":1}]}
the classes that extend from another class are added into list but they convert into empty in json.
is it jsonUtility Bug?
or its my class structure fail?
thx for help.