Data conversion guides

Merge JSON configuration files and keep exact numbers

·

A catalog team needs to apply a seasonal configuration on top of its usual settings. The change should update the page size, keep the original region and carry forward the existing stock tag.

JSON Merge Tool

Merge the catalog configurations

Choose Load example. Document A stores the current configuration shown below. Document B provides page.size of 50, tags containing seasonal, and active set to true.

Set Conflict strategy to Append arrays, then choose Merge JSON. The result keeps page.region as us and sets page.size to 50. Tags appear in document order as in-stock and seasonal. The id still reads 9007199254740993. Download merged.json and inspect the number in a text editor before passing the file to software that may round it.

Document A from the catalog example
{
  "page": {"size": 20, "region": "us"},
  "tags": ["in-stock"],
  "id": 9007199254740993
}

RFC 8259, JSON objects and numbers

Choose how shared values combine

Use Document B takes the second value when arrays or scalar values share a key. Keep Document A takes the first. Both merge nested objects recursively.

Combine unique array items keeps the first equal member and ignores object key order while comparing. It treats 1 and 1.0 as distinct number spellings. Report conflicts applies the same comparisons and shows the first differing property path. Use that strategy to inspect an unfamiliar update before deciding which values to keep.

Resolve duplicate keys inside their original file

Try replacing Document B with {"tags":["seasonal"],"tags":["clearance"]}. The tool identifies the second tags key in Document B. Decide which value is intended or combine the arrays before merging. Duplicate names within one object can produce different results across JSON readers.

RFC 8259, JSON objects and numbers

Common questions

Can I merge arrays at the root?

Provide an object at the root of both documents. Wrap each top-level array under the same property name to apply one of the array strategies.

Does the tool reinterpret numbers when I choose Compact JSON?

Compact mode removes indentation and spaces between tokens. Every retained number keeps the source characters, including an exponent or a negative zero.

Sources

Put it into practice.

Related guides