欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

C#获取Json文件的树节点

程序员文章站 2022-06-12 17:05:44
...

using System;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft;
using System.IO;
using System.Collections.Generic;
using System.Data;
using Newtonsoft.Json.Converters;

  string json = @"{
         'CPU': 'Intel',
         'PSU': '500W',
         'Drives': [
           'DVD read/writer'
           /*(broken)*/,
           '500 gigabyte hard drive',
           '200 gigabype hard drive'
         ]
      }";
   var jObject = JObject.Parse(json);
         // context.Response.Write(jObject["CPU"]);
        context.Response.Write(jObject.SelectToken("CPU"));
https://q.cnblogs.com/q/53249/