using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using Prime31;
public class JsonTest : MonoBehaviour
{
// Use this for initialization
void Start () {
Player player = new Player()
{
Name = "Lee",
Age = 19
};
string jsonString = Json.encode(player);
Debug.Log(jsonString);
player = Json.decode<Player>(jsonString);
Debug.Log(player.Name);
Debug.Log(player.Age);
List<Player> playerList = new List<Player>()
{
new Player() {Name = "wang", Age = 12},
new Player() {Name = "wang2", Age = 13},
new Player() {Name = "wang3", Age = 14},
new Player() {Name = "wang4", Age = 15},
new Player() {Name = "wang5", Age = 16},
};
string playerListString = Json.encode(playerList);
Debug.Log(playerListString);
List<Player> playerList2;
playerList2 = Json.decode<List<Player>>(playerListString);
foreach (var p in playerList2)
{
Debug.Log(p.Name);
Debug.Log(p.Age);
}
}
}
public class Player
{
public string Name;
public int Age;
}
P31RestKit.dll 2.0 Unity3d json
最新推荐文章于 2022-10-16 07:48:00 发布