当前位置:
编程学习 >
JS >>
C#编程操作JSON实例代码
实例代码如下:
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Newtonsoft.Json;
- namespace TestJson
- {
- class Program
- {
- static void Main(string[] args)
- {
- string json = "{"a":"sadsad","c":{"d":"adad"}}";
- //CCC ccc = new CCC();
- //ccc.d = "adad";
- //AAA aaa = new AAA();
- //aaa.a = "sadsad";
- //aaa.b = "dfgdg";
- //aaa.c = ccc;
- AAA aaa = new AAA();
- aaa= JavaScriptConvert.DeserializeObject(json);
- // string json = JavaScriptConvert.SerializeObject(aaa);
- // Console.WriteLine(json);
- Console.Read();
- }
- }
- public class AAA {
-
- private string m_a;
- public string a
- {
- get { return m_a; }
- set { m_a = value; }
- }
- private string m_b;
- public string b
- {
- get { return m_b; }
- set { m_b = value; }
- }
- private CCC m_c;
- public CCC c
- {
- get { return m_c; }
- set { m_c = value; }
- }
- }
-
- public class CCC
- {
- private string m_d;
- public string d
- {
- get { return m_d; }
- set { m_d = value; }
- }
- }
- }
补充:软件开发 , C# ,