Replies: 2 comments 1 reply
-
You could use the replacer parameter of var unordered = JSON.parse(text)
var newText = JSON.stringify(unordered, function(key, value) {
if (value && typeof value == "object" && !Array.isArray(value))
return Object.fromEntries(Object.entries(value).sort())
return value;
}, 4)
editor.setValue(newText) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hey @nightwing, Sure we can do that way, but I was thinking in keep the configs in the same order as it was stored and just providing an option to view it in an ordered manner -- then kinda "view original" to move it back to the original order. BTW, thanks for the feedback! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I was looking for a feature to sort a JSON object by key names alphabetically. In a scenario we have thousands of entries it would be great to have this feature and then easily locate the key we are searching for. I know that I can use the "search" feature, but another case could be to compare two objects. For example, in my case, I have two apps -- each of them have configs stored in the database -- and I want to compare both configs by walking though it.
This is my 2 cents of idea. 😄
Beta Was this translation helpful? Give feedback.
All reactions