How to sort JSON by key

Viewed 62

I want to sort by JSON key. However, I want to keep the original representation of the values. For example, if I use jq, the value may change. Is there any recommended tool for this?

For example, when I input the following JSON,

{
  "def": 1000000000000000000000,
  "abc": 1.000
}

I want to get the following output.

{
  "abc": 1.000,
  "def": 1000000000000000000000
}

However, if I run jq -sort-keys, I will get the following.

{
  "abc": 1,
  "def": 1e+21
}
1 Answers
Related