当前位置:网站首页>Unity Json 编写
Unity Json 编写
2022-07-02 13:11:00 【云小川】
Json 在线编辑 ,转化为解析类 网址:JSON转C#实体类-BeJSON.com
{
"ConfigInfo": [
{
"Name": "红色旅游",
"Audio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png",
"ParentPointItmes": [
{
"PointName": "红色旅游1",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png",
"ChildPointItmes": [
{
"PointName": "陈毅故居1",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "井冈山1",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "遵义会议旧址1",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
}
]
},
{
"PointName": "红色旅游2",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png",
"ParentPointItmes": [
{
"PointName": "陈毅故居2",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "井冈山2",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "遵义会议旧址3",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
}
]
}
]
},
{
"Name": "红色展厅",
"Audio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png",
"ParentPointItmes": [
{
"PointName": "红色展厅1",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png",
"ChildPointItmes": [
{
"PointName": "抗日战争纪念馆1",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "解放战争纪念馆1",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "建党100周年1",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
}
]
},
{
"PointName": "红色展厅2",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png",
"ChildPointItmes": [
{
"PointName": "抗日战争纪念馆2",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "解放战争纪念馆2",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "建党100周年2",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
}
]
}
]
},
{
"Name": "廉政教育",
"Audio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png",
"ParentPointItmes": [
{
"PointName": "廉政教育1",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png",
"ChildPointItmes": [
{
"PointName": "廉政一1",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "廉政一2",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "廉政一3",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
}
]
},
{
"PointName": "廉政教育2",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png",
"ChildPointItmes": [
{
"PointName": "廉政二1",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "廉政二2",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
},
{
"PointName": "廉政二3",
"PointAudio": "/Audios/1631001459775.mp3",
"ImageUrl": "/Images/香山纪念馆/2021-05-25 11_14_07_043.png"
}
]
}
]
}
]
}解析类:
//如果好用,请收藏地址,帮忙分享。
using System;
using System.Collections.Generic;
[Serializable]
public class ChildPointItmesItem
{
/// <summary>
///
/// </summary>
public string PointName;
/// <summary>
///
/// </summary>
public string PointAudio;
/// <summary>
///
/// </summary>
public string ImageUrl;
}
[Serializable]
public class ParentPointItmesItem
{
/// <summary>
///
/// </summary>
public string PointName;
/// <summary>
///
/// </summary>
public string PointAudio;
/// <summary>
///
/// </summary>
public string ImageUrl;
/// <summary>
///
/// </summary>
public List<ChildPointItmesItem> ChildPointItmes;
}
[Serializable]
public class ConfigInfoItem
{
/// <summary>
///
/// </summary>
public string Name;
/// <summary>
///
/// </summary>
public string Audio;
/// <summary>
///
/// </summary>
public string ImageUrl;
/// <summary>
///
/// </summary>
public List<ParentPointItmesItem> ParentPointItmes;
}
public class Root
{
/// <summary>
///
/// </summary>
public List<ConfigInfoItem> ConfigInfo;
}
调用方法:
public Transform transform;
void Start()
{
//找到文件
string jsonTest = File.ReadAllText("D:/Data.json", Encoding.UTF8);
//直接调用Unity提供的接口JsonUtility.FromJson即可实现解析
List<ConfigInfoItem> configInfo = JsonUtility.FromJson<Root>(jsonTest).ConfigInfo;
Debug.Log(jsonTest);
for (int i = 0; i < configInfo.Count; i++)
{
Debug.Log(configInfo[i].Name);
//GlobalFunction.CreationUI("ItmeList", transform);
}
}边栏推荐
- 数学分析_笔记_第6章:一元函数的Riemann积分
- Thinking about absolute truth and relative truth
- The median salary of TSMC's global employees is about 460000, and the CEO is about 8.99 million; Apple raised the price of iPhone in Japan; VIM 9.0 releases | geek headlines
- Boot 事务使用
- Summary | three coordinate systems in machine vision and their relationships
- Conditions and solutions of deadlock
- 虚假的暑假
- After the win10 system is upgraded for a period of time, the memory occupation is too high
- 【5G NR】RRC连接释放
- 华为云服务器安装mysqlb for mysqld.service failed because the control process exited with error code.See “sys
猜你喜欢

Text intelligent expansion and contraction control of swiftui text component (tutorial includes source code)

End time processing method of wechat v3native payment settings

去除router-link中的下划线

历史上的今天:支付宝推出条码支付;分时系统之父诞生;世界上第一支电视广告...

sim2real环境配置教程

Yyds dry inventory company stipulates that all interfaces use post requests. Why?

JS learning notes - first acquaintance

TypeScript数组乱序输出

Kubernetes family container housekeeper pod online Q & A?

idea jar包冲突排查
随机推荐
Mathematical analysis_ Notes_ Chapter 5: univariate differential calculus
解决** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the defau
数学分析_笔记_第6章:一元函数的Riemann积分
Add user-defined formula (time sharing t+0) to mobile app access as an example
Huawei ECS installs mysqlb for mysqld service failed because the control process exited with error code. See “sys
OSPF - detailed explanation of NSSA area and full NSSA area (including configuration command), LSA type 7 lsa-7
SSM integration exception handler and project exception handling scheme
Route service grid traffic through two-level gateway design
Invalid bound statement (not found)解决方法总结
Another graduation season
Various entanglements between qvariant and Jason -- QT
仙人掌之歌——投石问路(3)
JS learning notes - data types
Summary of monthly report | list of major events of moonbeam in June
Mysql database mysqldump why there is no statement to create a database
[solution] educational codeforces round 82
AWS virtual machine expansion
又是一年毕业季
AWS云主机扩容
Leetcode -- number of palindromes