MySQL 8.4Lab-verified · 2026-11-30

MySQL ERROR 3140 (22032): Invalid JSON text in value for column

A value going into a JSON column is not valid JSON text.

MySQL 8.4.13
3140 (22032): Invalid JSON text: "Missing a name for object member." at position 1 in value for column 'settings.options'.

Jump to a cause

  1. 01JSON written with single quotes
  2. 02Inserting an empty string into a JSON column
  3. 03Converting a TEXT column with bad rows to JSON

Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-30 · container image mysql:8.4

A JSON column only accepts valid JSON. When the value is not, MySQL rejects the whole statement with ERROR 3140. The quoted part of the message tells you what the parser found, and at position N is where it stopped.

Below are three cases from MySQL 8.4, each with a different quoted reason: "Missing a name for object member.", "The document is empty." and "Invalid value.". JSON_VALID() was used in each case to check the value before fixing it. This error has no Korean or Japanese translation, so the message is in English on every page.

01JSON written with single quotes

INSERT INTO settings VALUES (1, "{'theme': 'dark', 'size': 12}"); failed with "Missing a name for object member." at position 1. JSON keys and strings must use double quotes, so the parser could not read 'theme' as a member name.

JSON_VALID() returned 0 for the single-quoted text and 1 for {"theme": "dark"}. Inserting '{"theme": "dark", "size": 12}' (single quotes outside for SQL, double quotes inside for JSON) worked, and options->>'$.theme' returned dark.

Setup
Setuprun as lab_a
CREATE TABLE settings (id INT PRIMARY KEY, options JSON);
OUTPUT
Query OK, 0 rows affected (0.01 sec)
Reproducerun as lab_a
INSERT INTO settings VALUES (1, "{'theme': 'dark', 'size': 12}");
✕ ERROR
ERROR 3140 (22032): Invalid JSON text: "Missing a name for object member." at position 1 in value for column 'settings.options'.
Checkrun as lab_a
SELECT JSON_VALID("{'theme': 'dark'}") AS single_quote, JSON_VALID('{"theme": "dark"}') AS double_quote;
OUTPUT
+--------------+--------------+
| single_quote | double_quote |
+--------------+--------------+
|            0 |            1 |
+--------------+--------------+
1 row in set (0.00 sec)

Build the JSON in your application with a JSON library instead of string concatenation, then bind it as a parameter.

After the fixrun as lab_a
INSERT INTO settings VALUES (1, '{"theme": "dark", "size": 12}');
SELECT id, options, options->>'$.theme' AS theme FROM settings;
✓ SUCCESS
Query OK, 1 row affected (0.01 sec)

+----+-------------------------------+-------+
| id | options                       | theme |
+----+-------------------------------+-------+
|  1 | {"size": 12, "theme": "dark"} | dark  |
+----+-------------------------------+-------+
1 row in set (0.00 sec)

02Inserting an empty string into a JSON column

INSERT INTO settings VALUES (2, ''); failed with "The document is empty." at position 0. An empty string is not JSON, and MySQL does not turn it into NULL.

JSON_VALID('') returned 0 and JSON_VALID('{}') returned 1. Inserting NULL for row 2 and '{}' for row 3 both worked.

Setup
Setuprun as lab_a
CREATE TABLE settings (id INT PRIMARY KEY, options JSON);
OUTPUT
Query OK, 0 rows affected (0.02 sec)
Reproducerun as lab_a
INSERT INTO settings VALUES (2, '');
✕ ERROR
ERROR 3140 (22032): Invalid JSON text: "The document is empty." at position 0 in value for column 'settings.options'.
Checkrun as lab_a
SELECT JSON_VALID('') AS empty_string, JSON_VALID('{}') AS empty_object;
OUTPUT
+--------------+--------------+
| empty_string | empty_object |
+--------------+--------------+
|            0 |            1 |
+--------------+--------------+
1 row in set (0.00 sec)

If your form or CSV sends '' for "no value", convert it to NULL (or '{}') before the INSERT.

After the fixrun as lab_a
INSERT INTO settings VALUES (2, NULL), (3, '{}');
SELECT id, options FROM settings ORDER BY id;
✓ SUCCESS
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

+----+---------+
| id | options |
+----+---------+
|  2 | NULL    |
|  3 | {}      |
+----+---------+
2 rows in set (0.00 sec)

03Converting a TEXT column with bad rows to JSON

events.payload was TEXT with three rows. ALTER TABLE events MODIFY payload JSON; failed with "Invalid value.". The column name in the message was a temporary table such as '#sql-1_d6.payload', not events.payload, because the error came while copying rows.

SELECT id, payload FROM events WHERE JSON_VALID(payload) = 0; found two rows: type=logout (not JSON) and {"type": "view",} (trailing comma). After fixing those two rows with UPDATE, the same ALTER succeeded and payload->>'$.type' returned login, logout, view.

Setup
Setuprun as lab_a
CREATE TABLE events (id INT PRIMARY KEY, payload TEXT);
INSERT INTO events VALUES (1, '{"type": "login"}'), (2, 'type=logout'), (3, '{"type": "view",}');
OUTPUT
Query OK, 0 rows affected (0.02 sec)

Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0
Reproducerun as lab_a
ALTER TABLE events MODIFY payload JSON;
✕ ERROR
ERROR 3140 (22032): Invalid JSON text: "Invalid value." at position 1 in value for column '#sql-1_d6.payload'.
Checkrun as lab_a
SELECT id, payload FROM events WHERE JSON_VALID(payload) = 0;
OUTPUT
+----+-------------------+
| id | payload           |
+----+-------------------+
|  2 | type=logout       |
|  3 | {"type": "view",} |
+----+-------------------+
2 rows in set (0.00 sec)
Fixrun as lab_a
UPDATE events SET payload = '{"type": "logout"}' WHERE id = 2;
UPDATE events SET payload = '{"type": "view"}' WHERE id = 3;
OUTPUT
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
After the fixrun as lab_a
ALTER TABLE events MODIFY payload JSON;
SELECT id, payload->>'$.type' AS type FROM events ORDER BY id;
✓ SUCCESS
Query OK, 3 rows affected (0.03 sec)
Records: 3  Duplicates: 0  Warnings: 0

+----+--------+
| id | type   |
+----+--------+
|  1 | login  |
|  2 | logout |
|  3 | view   |
+----+--------+
3 rows in set (0.00 sec)

FAQ

What does "Missing a name for object member" mean in MySQL?

The JSON object has a key the parser cannot read as a name. On this page it was caused by single quotes: {'theme': 'dark'}. Changing it to {"theme": "dark"} fixed it.

Can I insert an empty string into a MySQL JSON column?

No. '' gave ERROR 3140 with "The document is empty.". Use NULL or a valid JSON value such as '{}'; both were accepted here.

How do I find the rows that break ALTER TABLE ... JSON?

Run SELECT id, payload FROM events WHERE JSON_VALID(payload) = 0; before the ALTER. It listed exactly the two bad rows on this page, and the ALTER worked after they were fixed.

Why does the error show a column like '#sql-1_d6.payload'?

That is the temporary table MySQL builds during ALTER TABLE. The real column is the one you are changing, here events.payload.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13