这是代码
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
public class csharpfile:MonoBehaviour{
public void LoadJson()
{
using (StreamReader r = new StreamReader("file.json"))
{
string json = r.ReadToEnd();
List<Item> items = JsonConvert.DeserializeObject<List<Item>>(json);
}
}
public class Item
{
public int millis;
public string stamp;
public DateTime datetime;
public string light;
public float temp;
public float vcc;
}
}
Run Code Online (Sandbox Code Playgroud)
现在我想解析文件内容(file.json)
[
{ "millis": "1000",
"stamp": "1273010254",
"datetime": "2010/5/4 21:57:34",
"light": "333",
"temp": "78.32",
"vcc": "3.54" },
]
Run Code Online (Sandbox Code Playgroud)
文件解析后我将如何在屏幕上打印内容以及如何写入文件 .do help …