using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using LitJson;
using System.Text;
public class parsejson : MonoBehaviour {
void Start () {
ParseJson(Application.streamingAssetsPath + "/Hint.ini");
}
void Update () {
}
public void ParseJson(string path)
{
bool isTxists = File.Exists(path);
if (isTxists)
{
string josntxt = File.ReadAllText(path,Encoding.Default);
Root HintsClass = JsonMapper.ToObject<Root>(josntxt); //得到josn类
Debug.Log(HintsClass.Hints[0].Hint);
}else
{
Debug.Log("文件不存在");
}
}
}
public class Hints
{
public string Hint { get; set; }
}
public class Root
{
public List<Hints> Hints { get; set; }
}
unity 用LitJson类库解析json文件方法
最新推荐文章于 2023-02-04 14:24:25 发布