当前位置:网站首页>An example of newtonjason
An example of newtonjason
2022-07-03 12:52:00 【superfreak】
person class The code is as follows :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewTonJSONTest
{
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public string[] Mobiles { get; set; }
}
}
The default class of a console program , It's also main Class Program The code is as follows :
using System;
using System.Collections.Generic;
using Newtonsoft.Json;//
using Newtonsoft.Json.Linq;//
namespace NewTonJSONTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
List<Person> person0;
List<Person> person = new List<Person>(){
new Person() {Name = "China Mobile", Age = 30, Mobiles = new string[] {"13800138000","10086"}},
new Person() {Name = "China Telecom", Age = 60, Mobiles = new string[] {"10000","189"}},
new Person() {Name = "China Unicom", Age = 90, Mobiles = new string[] {"10010"}}
};
// Serialize to JSON String
string str_json = JsonConvert.SerializeObject(person);
Console.WriteLine(str_json);
Console.WriteLine(" Serialization is complete , Serialized the object as a json character string ");
// Deserialize to Person List objects , Deserialization is *str_json character string Serialize as an object
person0 = JsonConvert.DeserializeObject<List<Person>>(str_json);
foreach (var temp in person0)
{
Console.WriteLine(temp.Age + " " + temp.Name + " " + temp.Mobiles + "\n");
}
// JObject oPostData = JsonConvert.DeserializeObject<JObject>(str_json); //@@
// oPostData.GetValue("Channel").ToString();//@@
}
}
}
Running results Here's the picture :
Hello World!
[{"Name":"China Mobile","Age":30,"Mobiles":["13800138000","10086"]},{"Name":"China Telecom","Age":60,"Mobiles":["10000","189"]},{"Name":"China Unicom","Age":90,"Mobiles":["10010"]}]
Serialization is complete , Serialized the object as a json character string
30 China Mobile System.String[]
60 China Telecom System.String[]
90 China Unicom System.String[]
D:\Users\86133\source\repos\NewTonJSONTest\NewTonJSONTest\bin\Debug\net5.0\NewTonJSONTest.exe ( process 28896) Exited , The code is 0.
To automatically close the console when debugging stops , Please enable “ Tools ”->“ Options ”->“ debugging ”->“ Automatically close the console when debugging stops ”.
Press any key to close this window . . .边栏推荐
- [comprehensive question] [Database Principle]
- Export the entire Oracle Database
- The solution to change the USB flash disk into a space of only 2m
- Flinksql can directly create tables and read MySQL or Kafka data on the client side, but how can it automatically flow and calculate?
- 【计网】第三章 数据链路层(2)流量控制与可靠传输、停止等待协议、后退N帧协议(GBN)、选择重传协议(SR)
- 记录自己vulnhub闯关记录
- Differences and connections between final and static
- Deeply understand the mvcc mechanism of MySQL
- Swift5.7 扩展 some 到泛型参数
- 剑指Offer09. 用两个栈实现队列
猜你喜欢

TOGAF认证自学宝典V2.0

Alibaba is bigger than sending SMS (user microservice - message microservice)

社交社区论坛APP超高颜值UI界面

Sword finger offer10- I. Fibonacci sequence

Glide question you cannot start a load for a destroyed activity

阿里大于发送短信(用户微服务--消息微服务)

剑指Offer05. 替换空格

Gan totem column bridgeless boost PFC (single phase) seven PFC duty cycle feedforward
![[network counting] Chapter 3 data link layer (2) flow control and reliable transmission, stop waiting protocol, backward n frame protocol (GBN), selective retransmission protocol (SR)](/img/45/c2d7934b886d8090373ca9e6e23c97.gif)
[network counting] Chapter 3 data link layer (2) flow control and reliable transmission, stop waiting protocol, backward n frame protocol (GBN), selective retransmission protocol (SR)

【数据库原理复习题】
随机推荐
ORM use of node -serialize
node的ORM使用-Sequelize
低代码平台国际化多语言(i18n)技术方案
01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
【習題七】【數據庫原理】
Xctf mobile--app3 problem solving
Nodejs+Express+MySQL实现登陆功能(含验证码)
[ArcGIS user defined script tool] vector file generates expanded rectangular face elements
Write a simple nodejs script
The solution to change the USB flash disk into a space of only 2m
How to stand out quickly when you are new to the workplace?
剑指Offer05. 替换空格
T430 toss and install OS majave 10.14
Project video based on Linu development
【判断题】【简答题】【数据库原理】
Sqoop1.4.4原生增量导入特性探秘
Bert running error: attributeerror: module'tensorflow contrib. tpu' has no attribute 'InputPipelineConfig'
最新版盲盒商城thinkphp+uniapp
Kung Fu pays off, and learning is done
[review questions of database principles]