当前位置:网站首页>. net daily thoughts - compare two JSON files and get data with the same tag but different values
. net daily thoughts - compare two JSON files and get data with the same tag but different values
2022-04-22 07:16:00 【Caramel macchiato】
Ideas : Value storage dictionary And then use linq Compare two dictionaries that are the same key Of value
// Get the full path of the current project
string path = Environment.CurrentDirectory;//C:\TestProject\ORMProject\bin\Debug\net6.0
// Read json file
string jsonfile1 = path + @"\appsetting.json";//JSON File path
string jsonfile2 = path + @"\appsetting2.json";//JSON File path
// analysis json The content in (linq to json)
System.IO.StreamReader file = new StreamReader(jsonfile1);
string js1 = file.ReadToEnd();
System.IO.StreamReader file2 = new StreamReader(jsonfile2);
string js2 = file2.ReadToEnd();
// To string
JObject josn1 = JObject.Parse(js1);
JObject josn2 = JObject.Parse(js2);
// Turn array
JProperty[] jps1 = josn1.Properties().ToList().ToArray<JProperty>();
JProperty[] jps2 = josn2.Properties().ToList().ToArray<JProperty>();
// Turn Dictionary
IDictionary<string, string> dic1 = jps1.ToDictionary(p => p.Name, p => p.Value.ToString());
IDictionary<string, string> dic2 = jps2.ToDictionary(p => p.Name, p => p.Value.ToString());
// Dictionary comparison
IDictionary<string, string> dict3 = dic2.Where(p => p.Value != dic1[p.Key].ToString()).ToDictionary(p => p.Key, p => p.Value);
版权声明
本文为[Caramel macchiato]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220608525559.html
边栏推荐
- common-net hp unix系统 ftp服务器 listFiles 返回为空解决方案。
- 日常开发随手记------VS上一些好用的设置
- Installer et modifier les chemins d'installation des plug - ins utools et vscode
- Does microelectronics major make chips? What is the chip related to?
- Nacos cluster configuration
- 利用线程工厂设定线程池中线程名称
- MongoDB安装自启动服务
- Li Kou 299: number guessing game
- leetcode 617 合并二叉树
- ASP.NET日常开发随手记------发送邮件
猜你喜欢

自己寻找一个记事本文件,数据素材自找,统计整个文本中,某三个关键字或者语句词条出现的次数。

假设成年人的体重和身高存在此种关系: 身高(厘米)-100=标准体重(千克) 如果一个人的体重与其标准体重的差值在正负5%之间,显示“体重正常”,其他则显示“体重超标”。编写程序,能处理用户输入的

Scope and lifetime (Mr. Weng Kai)

Nacos service provider registration

Nacos集群架构

微信第三方网页授权

What knowledge and skills need to be added to IC design?

Format control of format() method

再见了Postman,有一说一:Apifox才是YYDS

mysql的zip安装教程
随机推荐
【Bug小记】页面刷新后获取不到sessionstorage数据
定义类Shape作为父类,并在类中定义方法求周长和面积; (2)定义Shape子类圆形(circle),具有半径属性和常量PI,同时重写父类中的方法; (3)定义Shape子类长方形(rect
[SVN] subversion installation notes
SQLSERVER存储过程开发笔记----零碎问题以及关于操作文件的操作
Nacos集群架构
搭建ES6开发环境,实时编译
Distributed task scheduling and computing framework: powerjob advanced features - container 03
假设成年人的体重和身高存在此种关系: 身高(厘米)-100=标准体重(千克) 如果一个人的体重与其标准体重的差值在正负5%之间,显示“体重正常”,其他则显示“体重超标”。编写程序,能处理用户输入的
.NET学习笔记(一)----泛型的引入、优势、设计思想、原理、应用
Oracle JDK vs OpenJDK
Nacos持久化切换配置
PowerJob 工作流
ASP.NET日常开发随手记------iis服务器支持下载apk
微信第三方网页授权
分页
Vscode opens the applet and runs it to wechat developer tool wxml file compilation error
ASP. Net daily development notes ----- JS script executed in the background
Latex symbol and formula set
Notes on C # daily development ----- obtain all files in the zip in Huawei cloud bucket (including system. Notsupportedexception: "this stream does not support search operation" solution)
[bug notes] input: - WebKit autofill: the input box automatically fills in the background problem