如何比较大JSON?

编程入门 行业动态 更新时间:2024-10-24 05:20:50
本文介绍了如何比较大JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

通过代码从同一源创建了2个大的JSON(〜GB)文件,它们应该完全相同,但是有时应该会有一些细微的差异.

Have 2 big JSON (~GB) files created from same source by code, that should work exactly same, but there should be some small differences sometimes.

希望确保两次转换都能正确完成相同的工作.做了一个小项目,将JSON转换为CSV类型,并带有指向元素及其内容(单个值或数组/对象)的路径.然后计划通过任何文本差异来比较"CSV" JSON.

Want to be sure both conversions did same job and properly. Made small project to convert JSONs to kind of CSV with path to elements and its content (single value or arrays/objects). Planning to compare "CSV" JSONs by any text diff then.

来源(在我的GitHub上)相当长,有限制这里的空间并不是问题的主要部分.通常它不能正常工作(已在一个大型的简单JSON上进行了测试,并在此处显示了另一个示例,不想使用递归,代码非常棘手).

Source (on my GitHub) is quite long for limitted space here and is not main part of the question. It is not working properly generally (tested on a big simple JSON and another shown here, did not want to use recursion, code is quite tricky).

示例导出 JSON数据集示例#示例4 当ID设置为类型,水平格式全部排序时,说明我的想法如下:

Example export of JSON Data Set Sample # Example 4 to ilustrate my idea when ID set to type, Horizontal format and Sort All looks like:

batters\batter\Blueberry\ id 1003 batters\batter\Devil's Food\ id 1004 batters\batter\Chocolate\ id 1002 batters\batter\Regular\ id 1001 donut\ id 0001 name Cake ppu 0.55 topping\Glazed\ id 5002 topping\Chocolate with Sprinkles\ id 5006 topping\Chocolate\ id 5003 topping\Maple\ id 5004 topping\None\ id 5001 topping\Powdered Sugar\ id 5007 topping\Sugar\ id 5005

是个好主意还是有更好的选择?

已处理的JSON预览:

{ "type": "donut", "id": "0001", "name": "Cake", "ppu": 0.55, "batters": { "batter": [ { "id": "1001", "type": "Regular" },{ "id": "1002", "type": "Chocolate" },{ "id": "1003", "type": "Blueberry" },{ "id": "1004", "type": "Devil's Food" }]}, "topping": [ { "id": "5001", "type": "None" },{ "id": "5002", "type": "Glazed" },{ "id": "5005", "type": "Sugar" }, ...

推荐答案

至少有2个选项-在另一个问题中的第一处,并且在我的GitHub上将新方法 RemoveTwins 添加到Gason C ++中并转换为C#.

Have at least 2 options yet - 1st here in another question and new method RemoveTwins added to Gason C++ translated to C# - on my GitHub.

更多推荐

如何比较大JSON?

本文发布于:2023-10-24 14:46:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524217.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:比较大   JSON

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!