0

I am trying to store json data into a column with JSON data type in MySql.

Here is the table:

    CREATE DATABASE `testutf8` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
USE testutf8;
CREATE TABLE t2(jdoc JSON, sdoc TEXT);
INSERT INTO t2 VALUES('{"key1":"value1", "key2":"value2", "å": "value3"}','{"key1":"value1", "key2":"value2", "å": "value3"}');
SELECT * FROM t2;

However I get this result:

jdoc:
{"Ã¥": "value3", "key1": "value1", "key2": "value2"}    
sdoc:
{"key1":"value1", "key2":"value2", "å": "value3"}

Apparently the column with JSON data type doesn't encode the characters correctly.

How can I fix this?

Thanks in advance :)

5
  • How are you storing and retrieving the JSON? Maybe the encoding is wrong at another layer. Commented Jan 6, 2017 at 0:16
  • @shmosel: The codes above is how I stored and retrieve the JSON. So there is no another layer. Commented Jan 6, 2017 at 0:19
  • You can't run queries without some sort of client. Commented Jan 6, 2017 at 0:20
  • @shmosel: I'm running it in IntelliJ. Commented Jan 6, 2017 at 0:22
  • @shmosel: Yes it's the client's fault. Commented Jan 6, 2017 at 0:30

1 Answer 1

1

IntelliJ has encoding issue for JSON data type.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.