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
        }
    }
}
相关推荐
IMPYLH13 小时前
JSON.stringify 悄悄丢掉的字段
json
SEO_juper20 小时前
Node.js Product 结构化数据生成器:给产品页一键生成 JSON-LD
开发语言·前端·javascript·人工智能·node.js·json·1024程序员节
熊猫钓鱼>_>1 天前
Java处理JSON编程实用技巧
json
Thanks_ks2 天前
提示词工程实战:用结构化提示词让大模型输出稳定可控
python·大模型·json·openai·提示词工程·deepseek·系统提示词
SEO_juper3 天前
HTTPS 混合内容检查工具:页面全站 https 了,但还有 http 资源在拖后腿
开发语言·网络协议·http·https·node.js·json·bash
SeanQhl3 天前
行号会漂,指纹不会:一份可并发编辑的 JSON 清单怎么写
json
维爱智VR认知学能3 天前
VR课程软件版本迭代清单比对:资源哈希与依赖变更提取
json·哈希算法·vr
loopfde成序5 天前
Web-RAG 检索可见度评估体系与站点 JSON-LD 及 llms.txt 自动化核验实践
前端·自动化·json
麻瓜code10 天前
流式返回的工具参数是一段一段来的,怎么拼成一个 JSON
json
鲸渔12 天前
【AI Agent系列课程13-Python 基础13】JSON 读写:结构化数据交换基础
开发语言·python·json·ai编程