Unity 复杂Json 解析
2024-10-21 20:42:11
最近项目需要, 搞了一串嵌套非常多的Json 用LitJson读取体验不太好,上网查了一下发现NetwtonsoftJson ,十分好用
一句代码就可以了
JObject data = JsonConvert.DeserializeObject<JObject>(message);
其实也可以用LitJson方法
主要用法是把Json文件 格式化,然后搞清楚层级结构关系,创建一个对应类就可以直接转换了
APPStore appStore = JsonMapper.ToObject<APPStore>(message);
需要根据Json结构建好一个类 例如:
public class APPStore
{
public List<Category> data { get; set; }
} public class Category
{
public int id { get; set; }
public int pid { get; set; }
public string name { get; set; }
public int special { get; set; }
public List<AppCategory> child { get; set; }
} public class AppCategory
{
public int id { get; set; }
public int pid { get; set; }
public string name { get; set; }
public int special { get; set; }
public List<AppData> child { get; set; }
}
最新文章
- [CodeWars][JS]实现大整数加法
- 如何在Windows 2003+IIS6的环境下找回应用程序池(application pool)中的服务账号密码
- 细说 webpack 之流程篇
- app 尺寸
- tomcat+nginx+redis实现均衡负载、session共享(二)
- SVN 在 linux 下的配置
- 这两个成员函数inline重新virtual种类
- 2-jQuery - AJAX load() 方法【进阶篇】
- zookeeper入门系列:概述
- 咸鱼Chen
- [APIO2017]商旅(floyd+分数规划+SPFA)
- exists,in的区别-mysql
- [Swift]LeetCode806. 写字符串需要的行数 | Number of Lines To Write String
- P1546 最短网络 Agri-Net题解(克鲁斯卡尔)
- Angular4 组件间通讯
- git 之路
- json与csv的基础用与法
- php \r\n
- java代码示例(6-4)
- linux之 redis 的rdb 转 aof 及主从复
热门文章
- appium:报错Message: Message: Parameters were incorrect. We wanted {";required";:[";value";]}
- fastdfs java客户端操作
- python自动化-取消";Chrome正受到自动软件的控制";提示
- Dockerfile打包java应用
- react项目--路由封装
- HIVE- lag函数和lead函数
- python脚本打包
- TypeScript 学习之路
- (已解决)为什么最新版本(v4.3.1)的bootstrap不能使用center-block?
- Linux 第八节(防火墙 )