PRACTICAL GUIDES · Web and codes
JSON key order: comparing objects and arrays
Separate property order from array order. Read difference paths and check types, exact numbers and duplicate keys.
By Puffinmint · Updated
Unordered objects and ordered arrays
A JSON object is a collection of properties; an array is a sequence. Moving a property without changing its value can leave an object equivalent, whereas swapping two array elements changes the data.
Compare types and JSON Pointer paths
Compare types first: a numeric string is not a number, and null is not an absent property. Use JSON Pointer paths to locate changes. Slashes and tildes within property names are escaped in those paths.
-
Input
{"price":10,"tags":["a","b"]} {"tags":["a","c"],"price":10} -
Calculation steps
Choose and apply the method
-
Result
/tags/1: "b" → "c"
TRY THIS STEP
JSON compare: structural diff
Work inside this guide: load an example, run the tool and edit the inputs to compare results. The second experiment tests a different case.
A reproducible example
Objects with a price of 10 and tags are equivalent if only the property order changed. If the second array item changes from b to c, the path /tags/1 identifies the difference: array indexes start at zero.
Change only property order
The second example preserves the price and array and changes only property order: expect zero differences. Then reverse the array elements: changes appear at the index paths.
Result
Enter your values to see the result.
Locate the change at /tags/1
Objects with a price of 10 and tags are equivalent if only the property order changed. If the second array item changes from b to c, the path /tags/1 identifies the difference: array indexes start at zero.
Usage scenario
- Input
{"price":10,"tags":["a","b"]} {"tags":["a","c"],"price":10}- Result
/tags/1: "b" → "c"
Duplicate keys and exact numbers
Resolve duplicate keys before comparison because parsers can handle them differently. Numbers are compared exactly without binary rounding; 1 and 1.0 have equal values. The tool does not validate schemas, match objects by ID or reorder arrays.
These are example inputs, rather than measurements of a real case. Results use the full tool’s calculation engine. Compare them with the worked steps in this guide, then tick the checks after reviewing.
| Parameter | Value |
|---|---|
| What are the limits of this tool? | 100,000 characters per JSON, 60 levels and 10,000 values. Up to 500 displayed differences; exact numbers with up to 1,000 digits and normalized exponent ±10,000. |
| Processing and privacy | Inputs and results are processed in your browser and are not sent to the server. Aggregate statistics, when enabled, record only the tool and outcome, without the content. |