当前位置:网站首页>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);
}
}边栏推荐
- What are the necessary functions of short video app development?
- JS learning notes - variables
- The difference and usage of calloc, malloc and realloc functions
- [Xiaobai chat cloud] suggestions on container transformation of small and medium-sized enterprises
- 死锁的条件及解决方法
- 处理gzip: stdin: not in gzip formattar: Child returned status 1tar: Error is not recoverable: exitin
- [Yu Yue education] reference materials of sensing and intelligent control technology of Nanjing University of Technology
- Thinking about absolute truth and relative truth
- Today in history: Alipay launched barcode payment; The father of time-sharing system was born; The first TV advertisement in the world
- Typescript array out of order output
猜你喜欢

Mysql database mysqldump why there is no statement to create a database

sim2real环境配置教程

JS learning notes - variables

Classifier visual interpretation stylex: Google, MIT, etc. have found the key attributes that affect image classification

电脑设备打印机驱动安装失败如何解决

请问怎么在oracle视图中使用stustr函数

What is the difference between self attention mechanism and fully connected graph convolution network (GCN)?

Which software is good for machine vision?

做机器视觉哪个软件好?

Construction and business practice of Zhongke brain knowledge map platform
随机推荐
Which software is good for machine vision?
Sim2real environment configuration tutorial
数学分析_笔记_第6章:一元函数的Riemann积分
Mathematical analysis_ Notes_ Chapter 5: univariate differential calculus
Boot transaction usage
MySQL calculates the data within the longitude and latitude range
一文读懂AGV的关键技术——激光SLAM与视觉SLAM的区别
Some problems about MySQL installation
电脑管理员权限在哪里可以打开
Win11应用商店无法加载页面怎么办?Win11商店无法加载页面
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
The difference and usage of calloc, malloc and realloc functions
Another graduation season
分析超700万个研发需求发现,这8门编程语言才是行业最需要的!
Storage, reading and writing of blood relationship data of Nepal Graph & Data Warehouse
Mathematical analysis_ Notes_ Chapter 6: Riemann integral of univariate function
win10系统升级一段时间后,内存占用过高
数据安全产业系列沙龙(三)| 数据安全产业标准体系建设主题沙龙
多数据源配置代码
Write your own CPU Chapter 11 - learning notes