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. [bzoj4417] [洛谷P3990] [Shoi2013] 超级跳马

    Description 现有一个n行m列的棋盘,一只马欲从棋盘的左上角跳到右下角.每一步它向右跳奇数列,且跳到本行或相邻行.跳越期间,马不能离开棋盘.例如,当n = 3, m = 10时,下图是一种可 ...

  2. Qt Installer Framework翻译(4)

    教程:创建安装程序 本教程描述如何为一个小项目创建一个简单的安装程序: 本节描述创建安装程序所必须完成的步骤: 创建一个包文件夹,其中将包含所有配置文件和可安装的包. 创建一个配置文件,其中包含有关如 ...

  3. EFCore-脚手架Scaffold发生Build Failed问题的终极解决

    大家在使用EntityFrameworkCore的DBFirst的脚手架(Scaffolding)时应该遇到过Build Failed的错误,而没有任何提示,我也遇到过不少次,目前已经完美解决并将排查 ...

  4. python文件与输入输出

    注:本文档是学习<Python核心编程(第二版)>时的整理. 1.文件对象 文件对象不仅可以用来访问普通的磁盘文件,也可以访问任何其他类型抽象层面上的"文件".一旦设置 ...

  5. pyautogui介绍

    https://pyautogui.readthedocs.io/en/latest/introduction.html Introduction Purpose The purpose of PyA ...

  6. 机器学习-TensorFlow应用之 binned features, Cross features和optimizer

    概述 这一节主要介绍一下TensorFlow在应用的过程中的几个小的知识点,第一个是关于features的处理的,例如Bucketized (Binned) Features 和 Feature sc ...

  7. c#数字图像处理(四)线性点运算

    灰度图像的点运算可分为线性点运算和非线性点运算两种.4.1线性点运算定义线性点运算就是输出灰度级与输入灰度级呈线性关系的点运算.在这种情况下,灰度变换函数的形式为: g(x, y)=pf(x,y)+L ...

  8. 使用FileZilla Pro S3协议访问七牛云对象存储

    偶然发现FileZilla还有Pro版本,主要是比免费版多了一些协议支持,也偶然发现七牛云支持了S3协议接口,这样刚好弥补了其没有FTP的不足,于是找官方文档,折腾一下,使用FileZilla Pro ...

  9. jenkins集成jmeter-进阶篇

    1.gitlab自动触发jenkins构建 1⃣️安装插件: 2⃣️新建工程,设置git url,build when a change is pushed auto.sh /bin/sh echo ...

  10. CSS-14-浮动

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...