FormattersLesson 6Free preview
Sort JSON Keys
This lesson is part of Web Developer Tools · All levels
Summary
JSON Keys sort sort the key names of each object alphabetically, including the object that is nested. The order of the array elements is unchanged because the array order is part of the data. Consistent results make diff in Git easier to read and hash data more stable. This tool also helps when comparing two JSON files that have the same content but different key sequences.
Key points
- Sort the key object name alphabetically and recursively
- The order of the array elements is maintained because it is meaningful
- The value and data type remain unchanged
- Diff and hash become more stable between versions
- Duplicate keys can cause data loss on some parser
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.