可能是没有序列化。
加上类的上面加上[Serializable]就可以了。
如果是这样的格式:
{
{
"StudentDataList":
[
{
"Id":1,
"Name":"张三",
"StudentObjectScore":
[
{
"ObjectName":"Chinese",
"Score":80
},
{
"ObjectName":"Math",
"Score":90
},
{
"ObjectName":"English",
"Score":60
}
]
}
]
}
就需要这样写:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
[Serializable]
public class StudentDataWithJsonItem
{
public int Id;
public string Name;
public List<StudentObjectScore> StudentObjectScore;
}
[Serializable]
public class StudentObjectScore
{
public string ObjectName;
public int Score;
}
public class StudentData
{
public List<StudentDataWithJsonItem> StudentDataList;
}
我理解的是Json里面只要在 [] 里面的数据,那么就需要序列化
版权声明:本文为qq_52855744原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。