DBAtlas · Database operations atlas

3140: ER_INVALID_JSON_TEXT: Invalid JSON text

MySQL

What 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.

Open in DBAtlas →

More from this engine