日期:2014-05-17 浏览次数:20417 次
using System;
using System.Collections.Generic;
using System.Text;
using LitJson;
namespace ConsoleApplicationTest
{
class Program
{
static void Main(string[] args)
{
string source="{\"agent1\":{\"AgentName\":\"1\",\"RegisteName\":\"1\"},\"agent2\":{\"AgentName\":\"2\",\"RegisteName\":\"2\"}}";
List<string> target = new List<string>();
JsonData jsonData = JsonMapper.ToObject(source);//转成Json对象
for (int i = 0, count = jsonData.Count; i < count; i++)
{
target.Add(jsonData[i].ToJson());//直接将对象的值放进List里面
}
Console.WriteLine("[" + String.Join(",", target.ToArray()) + "]");
Console.ReadKey();
}
}
}