using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
using Newtonsoft.Json;
using System.Text; namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
DictionaryJsonDemo();
Console.ReadLine();
} static void DictionaryJsonDemo()
{
Dictionary<string, string> dic = new Dictionary<string, string>();
for (int i = ; i < ; i++)
{
string key = Guid.NewGuid().ToString();
dic.Add(key, key);
} var serializedJson = JsonConvert.SerializeObject(dic,Formatting.Indented);
Console.WriteLine("Serialized json:");
Console.WriteLine(serializedJson);
WriteContentToJson(serializedJson);
Dictionary<string, string> deserializedDic = JsonConvert.DeserializeObject<Dictionary<string, string>>(serializedJson);
foreach(var d in deserializedDic)
{
Console.WriteLine($"Key:{d.Key},Value:{d.Value}");
}
} static void WriteContentToJson(string msg)
{
string jsonFile = @"..\..\..\Resource\JsonFile.json";
using(StreamWriter msgWriter=new StreamWriter(jsonFile,false,Encoding.UTF8))
{
msgWriter.WriteLine(msg);
}
}
}

Relative file path @"..\formerdirectory",@"..\..\AboveTwoDir",@"..\..\..\AboveThreeDir";

C# NewtonJson Serialize and deserialize的更多相关文章

  1. [LeetCode] Serialize and Deserialize BST 二叉搜索树的序列化和去序列化

    Serialization is the process of converting a data structure or object into a sequence of bits so tha ...

  2. [LeetCode] Serialize and Deserialize Binary Tree 二叉树的序列化和去序列化

    Serialization is the process of converting a data structure or object into a sequence of bits so tha ...

  3. U家面试prepare: Serialize and Deserialize Tree With Uncertain Children Nodes

    Like Leetcode 297, Serialize and Deserialize Binary Tree, the only difference, this is not a binary ...

  4. Leetcode: Serialize and Deserialize BST

    Serialization is the process of converting a data structure or object into a sequence of bits so tha ...

  5. [LeetCode] Serialize and Deserialize Binary Tree

    Serialize and Deserialize Binary Tree Serialization is the process of converting a data structure or ...

  6. LeetCode——Serialize and Deserialize Binary Tree

    Description: Serialization is the process of converting a data structure or object into a sequence o ...

  7. Serialize and Deserialize Binary Tree

    Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a ...

  8. 449. Serialize and Deserialize BST——几乎所有树的面试题目都会回到BFS或者DFS,使用BFS,None节点存#

    Serialization is the process of converting a data structure or object into a sequence of bits so tha ...

  9. 297. Serialize and Deserialize Binary Tree

    题目: Serialization is the process of converting a data structure or object into a sequence of bits so ...

随机推荐

  1. Java入门 - 高级教程 - 07.多线程

    原文地址:http://www.work100.net/training/java-multi-threading.html 更多教程:光束云 - 免费课程 多线程 序号 文内章节 视频 1 概述 2 ...

  2. FindBugs报错

    FindBugs是基于Bug Patterns概念,查找javabytecode(.class文件)中的潜在bug,主要检查bytecode中的bug patterns,如NullPoint空指针检查 ...

  3. Entity Framework 6+ 连接Mysql

    好吧.这个博客开不开的 我感觉.. 都一样了. 前言: 公司改造Sqlserver ->Mysql Sql2016老夫对不住你啊.. 好 前沿结束. 需要的家伙: 1.mysql-for-vis ...

  4. 8、python运算符

    前言:本文主要介绍python中经常使用的6种运算符,分别是算术运算符.比较运算符.赋值运算符.逻辑运算符.身份运算符和成员运算符. (因为用法比较简单,这里只做介绍,有兴趣的可以自己敲代码运行一下) ...

  5. python类型-序列

    注:本文档主要是学习<Python核心编程(第二版)>时做的资料整理. 1.序列 序列的成员是有序排列的,并且可以通过下标偏移量访问到它的一个或者几个成员,包括字符串(普通字符串和Unic ...

  6. Deep server from scratch

    Deep server from scratch 1.install Ubuntu16.04 via flash2.wired Network by Ruijie3.install google4.S ...

  7. Linux基础:简介安装、常用命令和JDK、Mysql、Tomcat的安装

    一.Linux的简介 1.Linux的概述 Linux是基于Unix的开源免费的操作系统,由于系统的稳定性和安全性几乎成为程序代码运行的最佳系统环境.Linux是由Linus Torvalds(林纳斯 ...

  8. 含源码解析,深入Java 线程池原理

    从池化技术到底层实现,一篇文章带你贯通线程池技术. 1.池化技术简介 在系统开发过程中,我们经常会用到池化技术来减少系统消耗,提升系统性能. 在编程领域,比较典型的池化技术有: 线程池.连接池.内存池 ...

  9. Java:线程的六种状态及转化

    目录 Java:线程的六种状态及转化 一.新建状态(NEW) 二.运行状态(RUNNABLE) 就绪状态(READY) 运行状态(RUNNING) 三.阻塞状态(BLOCKED) 四.等待状态(WAI ...

  10. 计算机原理基础:DNS

    DNS服务的作用 将域名解析成IP地址 端口号:53 域名服务器 根域名服务器 所有的根域名服务器都知道所有的顶级域名服务器的域名和IP地址. 不管是哪一个本地域名服务器,若要对因特网上任何一个域名进 ...