Normalization, Merging, and Autowrapping of JSON Values This “last duplicate key wins”  behavior is suggested by RFC 7159 and is implemented by most JavaScript parsers. (Bug #86866, Bug #26369555) In versions of MySQL prior to 8.0.3, members with keys that duplicated a key found earlier in the document were discarded. The object value produced by the following  JSON_OBJECT()  call does not include the second  key1  element because that key name occurs earlier in the value: Prior to MySQL 8.0.3, this “first duplicate key wins”  normalization was also performed when inserting values into JSON columns. MySQL also discards extra whitespace between keys, values, or elements in the original JSON document, and leaves (or inserts, when necessary) a single space following each comma ( , ) or colon ( : ) when displaying it. This is done to enhance readibility. MySQL functions that produce JSON values (see Section 12.18.2, “Functions That Create JSON Values” ) always return normalized values. To make lookups more efficient, MySQL also sorts the keys of a JSON object.  You should be aware that the result of this ordering is subject to change and not guaranteed to be consistent across releases . Two merging algorithms are supported in MySQL 8.0.3 (and later), implemented by the functions JSON_MERGE_PRESERVE()  and  JSON_MERGE_PATCH() . These differ in how they handle duplicate keys: JSON_MERGE_PRESERVE()  retains values for duplicate keys, while  JSON_MERGE_PATCH()  discards all but the last value. The next few paragraphs explain how each of these two functions handles the merging of different combinations of JSON documents (that is, of objects and arrays). JSON_MERGE_PRESERVE()  is the same as the  JSON_MERGE()  function found in previous versions of MySQL (renamed in MySQL 8.0.3).  JSON_MERGE()  is still supported as an alias for  JSON_MERGE_PRESERVE()  in MySQL 8.0, but is deprecated and subject to removal in a future release. Merging arrays.   In contexts that combine multiple arrays, the arrays are merged into a single array. JSON_MERGE_PRESERVE()  does this by concatenating arrays named later to the end of the first array. JSON_MERGE_PATCH()  considers each argument as an array consisting of a single element (thus having Note Merging JSON Values mysql>  SELECT JSON_OBJECT(’key1’, 1, ’key2’, ’abc’, ’key1’, ’def’); +------------------------------------------------------+ | JSON_OBJECT(’key1’, 1, ’key2’, ’abc’, ’key1’, ’def’) | +------------------------------------------------------+ | {"key1": 1, "key2": "abc"} | +------------------------------------------------------+ mysql>  CREATE TABLE t1 (c1 JSON); mysql>  INSERT INTO t1 VALUES > (’{"x": 17, "x": "red"}’), > (’{"x": 17, "x": "red", "x": [3, 5, 7]}’); mysql>  SELECT c1 FROM t1; +-----------+ | c1 | +-----------+ | {"x": 17} | | {"x": 17} | +-----------+ 2074