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
        }
    }
}
相关推荐
talle20211 天前
Hive | json数据处理
hive·hadoop·json
一起养小猫1 天前
Flutter for OpenHarmony 实战:网络请求与JSON解析完全指南
网络·jvm·spring·flutter·json·harmonyos
雪碧聊技术1 天前
JSON数据格式
json·fastjson
从此不归路1 天前
Qt5 进阶【12】JSON/XML 数据协议处理:与后端/配置文件的对接
xml·开发语言·c++·qt·json
说给风听.2 天前
零基础学 JSON:原理、语法与应用全解析
json
天若有情6732 天前
XiangJsonCraft v1.2.0重大更新解读:本地配置优先+全量容错,JSON解耦开发体验再升级
前端·javascript·npm·json·xiangjsoncraft
Sylvia33.2 天前
足球“文字直播/事件流”API详解:解码比赛的数字DNA
java·服务器·前端·json
Elieal2 天前
统一 JSON 格式,JacksonObjectMapper 定制 Spring Boot JSON 转换规则
spring boot·json·状态模式
像风一样自由20203 天前
解决百度网盘安装报错:D 盘 package.json 触发 Electron ESM/CJS 冲突
javascript·electron·json
灰太狼大王灬3 天前
OCR-RenameStudio是一个基于 PaddleOCR-json的桌面工具——Umi-OCR 智能重命名助手
json·ocr