C#2010 .NET4 解析 json 字符串

下载Newtonsoft.Json.dll

cs 复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string jsonString = "{\"name\":\"Alice\",\"age\":25}";
            JObject jsonObject = JObject.Parse(jsonString);

            string name = jsonObject["name"].ToString();
            name = jsonObject.Value<string>("name");
            int age = jsonObject.Value<int>("age");

            Console.WriteLine("Name: " + name);  // 输出:Name: Alice
            Console.WriteLine("Age: " + age);  // 输出:Age: 25
        }
    }
}
相关推荐
njsgcs3 天前
json转excel python pd
python·json·excel·pd
代码搬运媛3 天前
【架构相关】tsconfig.json 与 tsconfig.node.json、tsconfig.app.json 的关系和作用
node.js·json
aerror4 天前
json转excel xlsx文件
开发语言·python·json
掉鱼的猫5 天前
全球首个支持 IETF JSONPath (RFC 9535) 标准的 Java 框架,Snack4-Jsonpath v4.0.0 发布
java·json
吹个口哨写代码5 天前
处理文本编辑器存的json格式报错问题,对编辑器存的字段进行转换处理,再通过json返回
java·编辑器·json
APIshop5 天前
代码实例:Python 爬虫抓取与解析 JSON 数据
爬虫·python·json
得物技术6 天前
从 JSON 字符串到 Java 对象:Fastjson 1.2.83 全程解析|得物技术
java·后端·json
GISBox6 天前
GISBox如何让GeoTIFF突破Imagery Provider加载限制?
react.js·json·gis
C嘎嘎嵌入式开发6 天前
(20)100天python从入门到拿捏《JSON 数据解析》
开发语言·python·json
LazerYvTian7 天前
Json数据字段类型兼容性处理
json