当前位置:网站首页>Unity jsonutility failed to serialize list
Unity jsonutility failed to serialize list
2022-06-13 01:31:00 【Last zero】
1、 The phenomenon
JsonUtility.ToJson Serialized as {}
2、 reason
although Unity Provides JsonUtility, but List Cannot be serialized and stored directly
3、 Solution
Custom class
3.1 Add code
[Serializable]
public class Serialization<T>
{
[SerializeField]
List<T> target;
public List<T> ToList() {
return target; }
public Serialization(List<T> target)
{
this.target = target;
}
}
3.2 Use
Ranking For the class to serialize
string result = JsonUtility.ToJson(new Serialization<Ranking>(rankingList));
return JsonUtility.FromJson<Serialization<Ranking>>(list).ToList();
边栏推荐
- Phaser3 load
- Lecture on Compilation Principles
- RSA encryption colloquial explanation
- Understanding of the detach() function of pytorch
- Wikipedia API User Guide
- 关于#数据库#的问题,如何解决?
- The interviewer only asked me five questions and the interview was over
- Idea installation tutorial
- How to solve the problems when using TV focusable to package APK in uni app
- Leetcode 01 array
猜你喜欢

What kind of experience is it to be a software test engineer in a state-owned enterprise: every day is like a war

DFS and BFS notes (II): depth first search (implemented in C language)

pycharm add configutions

Ecological convergence NFT attacks, metaverse ape leads the new paradigm revolution of Web 3.0 meta universe

Summary of various installation methods of Lab View

How does Apple add QQ email?

Uuid/guid introduction, generation rules and generation codes

A problem discovery and attempted solution to the strange stop of server script

MySQL connection query

The storage structure of a tree can adopt the parent representation, that is, the parent pointer array representation. Try to give the corresponding class definition. Each tree node contains two membe
随机推荐
他山之石:a16z 的 Web3 投资版图
4K sea bottom and water surface fabrication method and ocean bump displacement texture Download
Large end storage and small end storage
On February 26, 2022, the latest news of national oil price adjustment today
QT color extraction
Wikipedia User Guide
ng-tv-focusable
Leetcode 05 tree
5G工业网关在煤矿行业的应用优势
leetcode 142. Circular linked list II
Golang learning essay
Project training (XVII) -- personal work summary
Three paradigms of database
Tweens of phaser3
Tweets movement description and chart display
leetode. 242. valid Letter heteronyms
Application advantages of 5g industrial gateway in coal industry
在国企做软件测试工程师是一种什么样的体验:每天过的像打仗一样
Leetcode-17- letter combination of phone number (medium)
[Andoid][踩坑]CTS 11_r3开始出现的testBootClassPathAndSystemServerClasspath_nonDuplicateClasses FAIL问题分析