当前位置:网站首页>C# Newtonsoft. Use of job in JSON
C# Newtonsoft. Use of job in JSON
2022-07-01 07:09:00 【Xiongsiyu】
Catalog
Case study 1
json
{
"Name": "Jack",
"Age": 34,
"Colleagues": [{
"Name": "Tom",
"Age": 44
}, {
"Name": "Abel",
"Age": 29
}]
}Code
using Newtonsoft.Json.Linq;
using System;
namespace JObject Case study
{
class Program
{
static void Main(string[] args)
{
string json = "{\"Name\" : \"Jack\", \"Age\" : 34, \"Colleagues\" : [{\"Name\" : \"Tom\" , \"Age\":44},{\"Name\" : \"Abel\",\"Age\":29}] }";
JObject jObject1 = JObject.Parse(json);
string name = jObject1["Name"].ToString();
string age = jObject1["Age"].ToString();
string colleagues1_name = jObject1["Colleagues"][0]["Name"].ToString();
string colleagues1_age = jObject1["Colleagues"][0]["Age"].ToString();
Console.WriteLine(name);
Console.WriteLine(age);
Console.WriteLine(colleagues1_name);
Console.WriteLine(colleagues1_age);
Console.ReadKey();
}
}
}
function

Case study 2
json
{
"ID": 1,
"Name": " Zhang San ",
"Favorites": [" having dinner ", " sleep "]
}Code
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
namespace JObject Case study
{
class Program
{
static void Main(string[] args)
{
string json = "{\"ID\":1,\"Name\":\" Zhang San \",\"Favorites\":[\" having dinner \",\" sleep \"]}";
JObject jObject1 = JObject.Parse(json);
Console.WriteLine(jObject1["ID"]);
Console.WriteLine(jObject1["Name"]);
Console.WriteLine(jObject1["Favorites"][0]);
Console.WriteLine(jObject1["Favorites"][1]);
Console.ReadKey();
}
}
}
function

Case study 3
json
{
"input": {
"size": 193156,
"type": "image/png"
},
"output": {
"size": 59646,
"type": "image/png",
"width": 487,
"height": 284,
"ratio": 0.3088,
"url": "https://www.baidu.com"
}
}Code
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Text;
namespace JObject Case study
{
class Program
{
static void Main(string[] args)
{
string json = "{\"input\":{\"size\":193156,\"type\":\"image/png\"},\"output\":{\"size\":59646,\"type\":\"image/png\",\"width\":487,\"height\":284,\"ratio\":0.3088,\"url\":\"https://www.baidu.com\"}}";
JObject jObject1 = JObject.Parse(json);
Console.WriteLine(jObject1["input"]["size"]);
Console.WriteLine(jObject1["input"]["type"]);
Console.WriteLine(jObject1["output"]["size"]);
Console.WriteLine(jObject1["output"]["type"]);
Console.ReadKey();
}
}
}
function

Case study 4
json
{
"code": "SUCCESS",
"msg": null,
"data": [{
"id": 31783735,
"residentInfoId": 2000099151,
"doctorId": "89bd0716-f916-4e51-93f7-4d416830f03c"
}]
}Code
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Text;
namespace JObject Case study
{
class Program
{
static void Main(string[] args)
{
string json = "{\"code\":\"SUCCESS\",\"msg\":null,\"data\":[{\"id\":31783735,\"residentInfoId\":2000099151,\"doctorId\":\"89bd0716-f916-4e51-93f7-4d416830f03c\"}]}";
JObject jObject1 = JObject.Parse(json);
Console.WriteLine(jObject1["code"]);
Console.WriteLine(jObject1["SUCCESS"]);
Console.WriteLine(jObject1["data"][0]["id"]);
Console.WriteLine(jObject1["data"][0]["residentInfoId"]);
Console.WriteLine(jObject1["data"][0]["doctorId"]);
Console.ReadKey();
}
}
}
function

end
边栏推荐
- We found a huge hole in MySQL: do not judge the number of rows affected by update!!!
- Are there any practical skills for operation and maintenance management
- Operation and maintenance management system, humanized operation experience
- ctfshow-web355,356(SSRF)
- 【分类模型】Q 型聚类分析
- Why are so many people turning to product managers? What is the development prospect of product manager?
- Jena基于OWL的默认推理查询
- Introduction to spark (one article is enough)
- buildroot override 机制
- [the path of system analysts] Chapter 5: software engineering of double disk (reverse clean room and Model Driven Development)
猜你喜欢

【推荐技术】基于协同过滤的网络信息推荐技术matlab仿真

灰度何以跌下神坛?

Esp32 esp-idf ADC monitors battery voltage (with correction)

Fix the problem that the AI video intelligent platform easycvr device video cannot be played

Unity2021-Scene视图中物体无法直接选中的解决办法

JSP - 分页

电脑有网络,但所有浏览器网页都打不开,是怎么回事?

解决kaniko push镜像到harbor时报错(代理导致):unexpected status code 503 Service Unavailable

(I) apple has open source, but so what?

Understanding of Turing test and Chinese Room
随机推荐
[classification model] Q-type cluster analysis
Esp32 - ULP coprocessor reading Hall sensor in low power mode
Spark入门(一篇就够了)
赌上了绩效,赢了公司CTO,我要搭DevOps平台!
微软宣布开源 (GODEL) 语言模型聊天机器人
rclone中文文档:常用命令大全
【FPGA帧差】基于VmodCAM摄像头的帧差法目标跟踪FPGA实现
Problem: officeexception: failed to start and connect (II)
How the esp32 deep sleep current is lower than 10uA
[recommendation technology] matlab simulation of network information recommendation technology based on collaborative filtering
Easynvs cloud management platform function reconfiguration: support adding users, modifying information, etc
Product learning (I) - structure diagram
AI视频智能平台EasyCVR设备录像出现无法播放现象的问题修复
Jena default inference query based on OWL
rclone配置minio及基本操作
Is it safe to do fund fixed investment on Great Wall Securities?
為什麼這麼多人轉行產品經理?產品經理發展前景如何?
go-etcd
解决无法读取META-INF.services里面定义的类
Jena基于OWL的默认推理查询