Json  百度百科:传送门

  LitJson创建和解析Json  传送门

  Json数据解析在Unity3d中的应用  传送门

 

一、使用JsonUnity创建Json

Unity3D_(数据)JsonUtility创建和解析Json

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

[Serializable]
public class Person
{
    public string name;
    public int age;
}

public class JSON_Gary : MonoBehaviour {

    // Use this for initialization
    void Start () {
        //Json操作 两种方式 ListJson JsonUtility
        //使用代码的方式创建一个json
        //{'name':'Gary','age':20}

        Person p1 = new Person();
        p1.name = "Gary";
        p1.age = 20;
        //转成json字符串
        string jsonStr = JsonUtility.ToJson(p1);
        Debug.Log(jsonStr);

    }
    
}
JSON_Gary.cs

相关文章:

  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2022-01-13
  • 2021-11-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-30
  • 2021-05-10
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
相关资源
相似解决方案