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. 9.Java三大版本以及JDK,JRE,JVM简单介绍

    Write Once,Run Anywhere. JavaSE:标准版(桌面程序,控制台开发...),是Java的基础和核心. JavaME:嵌入式开发(手机,小家电...),现在基本不用已经过时. ...

  2. 个人第三次作业——结对编程 (姜玖林&于丁)

    博客要求 Github项目地址:https://github.com/zhibihuayue/PairProgramming 作业地址 : https://www.cnblogs.com/cheris ...

  3. python下的selenium和chrome driver的安装

    selenium是一款支持多种语言.多种浏览器.多个平台的开源web自动化测试软件,测试人员可用python.java等语言编写自动化脚本,使得浏览器可以完全按照你的指令运行,大大节省了测试人员用鼠标 ...

  4. HDFS NameNode重启优化

    http://tech.meituan.com/namenode-restart-optimization.html 一.背景 在Hadoop集群整个生命周期里,由于调整参数.Patch.升级等多种场 ...

  5. 讲解 json 和 pickle 模块

    首先是引入json 和 pickle 的原因是 普通的方法支持的数据类型太少 局限性大  比如下面的例子 dit = {'name':'deng1mei','age':'26','sex':'girl ...

  6. 通过 SCF Component 轻松构建 REST API,再也不用熬夜加班了

    本教程将分享如何通过 Serverless SCF Component .云函数 SCF 及 API 网关组件,快速构建一个 REST API 并实现 GET/PUT 操作. 当一个应用需要对第三方提 ...

  7. vue-父组件向子组件传值

    一.父组件向子组件传值 其实该问题是说子组件如何访问父组件的属性和方法?那么根据对组件化的理解,无非就是要解决两个问题: 1.父组件如何将值传给子组件? 2.子组件如何获取父组件传递过来的值? 解读v ...

  8. c++中各类型数据占据的字节长度

    c++中各种类型数据类型占据字节长度 首先罗列一下C++中的数据类型都有哪些: 1.整形:int.long 2.字符型:char.wchar_t 3.布尔型:bool 4.浮点型:float.doub ...

  9. 物流跟踪API-快递单推送

    上一篇文章我们讲解了订阅服务功能.我们已经完成了如何把物流订单订阅到快递鸟,快递鸟也能接收到我们的订单信息,接下来就需要快递鸟实时的将最新的物流轨迹推送到我们服务器,我们既然要接收快递鸟的信息,就需要 ...

  10. TortoiseSVN的安装及其简单使用

    VisualSVN-Server的安装以及简单使用 TortoiseSVN的安装及其简单使用 VisualSVN的安装及冲突的处理 安装完VisualSVN-Server后,Test仓储里边什么都没有 ...