3140: ER_INVALID_JSON_TEXT: Invalid JSON text
MySQLWhat does it mean?
Invalid (syntactically broken) JSON text was passed to a JSON column or JSON function. MySQL rejects the operation because it cannot parse the value as JSON.
Why does it happen?
An unclosed quote/bracket, a trailing comma, single quotes, escape character errors, or plain text sent to a JSON column. Appears when malformed text is passed to functions such as JSON_SET, JSON_INSERT, or to a JSON-typed column.
How to fix it
Fix the JSON text to valid syntax: use double quotes, remove trailing commas, verify escapes. Test whether the text is valid: SELECT JSON_VALID('{...}'); (returns 1 if valid). Use a reliable library to serialize JSON in the application layer and validate it before sending it to the server.
More from this engine
- 1118ER_TOO_BIG_ROWSIZE: Row size too large
- 1170ER_BLOB_KEY_WITHOUT_LENGTH: BLOB/TEXT column used in key specification without a key length
- 1592ER_BINLOG_UNSAFE_STATEMENT: Unsafe statement written to the binary log
- 1526ER_NO_PARTITION_FOR_GIVEN_VALUE: Table has no partition for value
- 1049Unknown database 'name'
- 1364Field 'name' doesn't have a default value
- 1206The total number of locks exceeds the lock table size