using Newtonsoft.Json; using System.Collections.Generic; using UnityEngine; public class JsonDe : MonoBehaviour { public class Produc { public string name = "sdf"; public int a = 1; public bool b = true; public float c = 2.1f; public Dictionary<string, string> dic = new Dictionary<string, string> { { "sdfsd", "654" }, { "dfsdf", "354" } }; public string[] ss = { "sdfsdf", "3213", "sdfsdf" }; public int[,] ves = new int[1, 2] { { 1, 2 } }; } void Start() { Produc produc = new Produc(); string json = JsonConvert.SerializeObject(produc); Debug.Log(json); Produc m = JsonConvert.DeserializeObject<Produc>(json); Debug.Log(m.ves[0, 0]); } }
需要用到Newtonsoft.Json.dll, 放到Plugins文件夹下面
csdn下载链接 https://download.csdn.net/download/gp1320099322/11932181
原文地址:https://www.cnblogs.com/G993/p/11751818.html
时间: 2024-10-15 17:00:59