CSharp · Console
using System;
public static class Program
{
public static void Main()
{
// Serialize JSON to object
var fromJson = "[{\"BattleCfg\":\"10_03_001\",\"SceneName\":\"RoomBall\",\"Item1\":\"1\",\"Prev\":\"0\",\"Item2\":\"2\",\"Next\":\"2\",\"Hp\":\"8\",\"Item3\":\"3\",\"Id\":\"1\",\"Name\":\"01\"}]";
var fromObject = LitJson.JsonMapper.ToObject<Config[]>(fromJson);
foreach(var config in fromObject)
{
Console.WriteLine(config);
}
}
public class Config
{
public string BattleCfg { get; set; }
public string SceneName { get; set; }
public string Item1 { get; set; }
public string Prev { get; set; }
public string Item2 { get; set; }
public string Next { get; set; }
public string Hp { get; set; }
public string Item3 { get; set; }
public string Id { get; set; }
public string Name { get; set; }
public override string ToString()
{
return string.Format(
"BattleCfg: {0}, SceneName: {1}, Item1: {2}, Prev: {3}, Item2: {4}, Next: {5}, Hp: {6}, Item3; {7}, Id: {8}, Name: {9}",
BattleCfg,
SceneName,
Item1,
Prev,
Item2,
Next,
Hp,
Item3,
Id,
Name
);
}
}
}