Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Minor
-
Resolution: Unresolved
-
10.11.2, 10.7.8, 10.8.7, 10.9.5, 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11, 11.0(EOL)
-
None
Description
When using the JSON_OBJECT function with ZEROFILL values, "malformed" JSON strings are generated, this occurs because it puts one or more 0s before the number. The JSON MariaDB own's functions fail to parse the string. Ej:
CREATE OR REPLACE TEMPORARY TABLE tTest( |
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, |
zeroInt INT(2) UNSIGNED ZEROFILL |
);
|
|
INSERT INTO tTest SET zeroInt = 1; |
|
SELECT JSON_OBJECT( |
'validProp1', 1, |
'zeroInt', zeroInt, |
'validProp2', 2 |
) INTO @json |
FROM tTest; |
|
SELECT
|
@json,
|
JSON_VALUE(@json, '$.validProp1') validProp1, |
JSON_VALUE(@json, '$.zeroInt') zeroInt, |
JSON_VALUE(@json, '$.validProp2') validProp2; |
Wich results in:
+--------------------------------------------------+----------+-------+----------+
|
| @json |validProp1|zeroInt|validProp2|
|
+--------------------------------------------------+----------+-------+----------+
|
| {"validProp1": 1, "zeroInt": 01, "validProp2": 2}|1 |0 | |
|
+--------------------------------------------------+----------+-------+----------+
|
The same JSON string also fails to parse with native Javascript JSON.parse() function.
JSON.parse('{"validProp1": 1, "zeroInt": 01, "validProp2": 2}')
|
|
> Uncaught SyntaxError: JSON.parse: expected ',' or '}' after property value in object at line 1 column 31 of the JSON data...
|
Attachments
Issue Links
- is duplicated by
-
MDEV-32692 JSON_OBJECT creates invalid json for zerofill columns
- Closed