答案 0 :(得分:3)
为什么要对数据进行排序?
JSON规范(JSON RFC(RFC 4627))说密钥顺序并不重要。大多数JSON实现都会以最有效的内存方式对它们进行排序。
如果你真的需要以排序的,缩进的格式输出它们(也许是为了能够阅读它们的人类),你将不得不使用某种编程语言(也许是python)来循环数据,按照您想要的方式对数据进行排序,然后将其输出到文本文件中。
但重申一下:JSON的关键排序对任何表现良好的软件都不重要。
答案 1 :(得分:0)
If you are managing your files locally, and using Sublime Text - you can easily cut and paste yourself to concatenate or merge these 2 files. Just delete the opening { and ending } brackets from the file you are cutting and pasting from. The paste the contents of the 2nd file inside the closing bracket } of the first file, after inserting a comma right before your pasted data.
If you don't care about the order of this data, that would be your easiest solution. But if you want it to look like your "Expected Result" - you'd have to use Javascript or Python to output the data from the 2nd file with the fields in the same order as the first file.