当前位置:网站首页>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
边栏推荐
- [Electrical dielectric number] electrical dielectric number and calculation considering HVDC and facts components
- 熱烈祝賀五行和合酒成功掛牌
- Automated test platform (13): interface automation framework and platform comparison, application scenario analysis and design ideas sharing
- Esp32 monitors the battery voltage with ULP when the battery is powered
- How to draw a product architecture diagram?
- 发现了一个 MySQL 的巨坑:update 更新别再用影响行数做判断了!!!
- Figure out the difference between event coordinates screenx, clientx, pagex and offsetx
- ctfshow-web355,356(SSRF)
- Mysql与Redis一致性解决方案
- [classification model] Q-type cluster analysis
猜你喜欢

【剑指offer&牛客101】中那些高频笔试,面试题——链表篇

LeetCode+ 71 - 75

C语言实现【扫雷游戏】完整版(实现源码)

【计网】(一) 集线器、网桥、交换机、路由器等概念
![[FPGA frame difference] FPGA implementation of frame difference target tracking based on vmodcam camera](/img/0f/045957961725716435439316078347.png)
[FPGA frame difference] FPGA implementation of frame difference target tracking based on vmodcam camera

ctfshow-web352,353(SSRF)

继妹变继母,儿子与自己断绝关系,世界首富马斯克,为何这么惨?

Solution to the problem that objects in unity2021 scene view cannot be directly selected

Image style migration cyclegan principle
![C language implementation [Sanzi chess game] (step analysis and implementation source code)](/img/3b/d32b46292ed20f31a6e1db97349df1.png)
C language implementation [Sanzi chess game] (step analysis and implementation source code)
随机推荐
如何进入互联网行业,成为产品经理?没有项目经验如何转行当上产品经理?
运维管理系统,人性化操作体验
【计网】(一) 集线器、网桥、交换机、路由器等概念
Rclone access web interface
Insufficient free space after clearing expired cache entries - consider increasing the maximum cache space
Ctfhub port scan (SSRF)
C# 读写自定义的Config文件
解决kaniko push镜像到harbor时报错(代理导致):unexpected status code 503 Service Unavailable
Router 6/ and the difference with router5
[Tikhonov] image super-resolution reconstruction based on Tikhonov regularization
Jena default inference query based on OWL
在长城证券上做基金定投安全吗?
Problem solving: officeexception: failed to start and connect (I)
运维面临挑战?智能运维管理系统来帮您
Figure out the difference between event coordinates screenx, clientx, pagex and offsetx
Which securities company is better or safer for mobile phone account opening
电脑有网络,但所有浏览器网页都打不开,是怎么回事?
8 figures | analyze Eureka's first synchronization registry
Is it safe to buy funds on the brokerage account
Understanding of Turing test and Chinese Room