3

I want to store a JSON object in MySQL database(using xampp with mariadb). What should be the data type to store? It gives error if 'json' is used as data type.

5
  • 1
    What is the MariaDB version? Commented Jan 26, 2017 at 14:55
  • There is no such thing as a "json object". JSON is a string, it is a format that represents arbitrary data as a string. Therefore you simply use a varchar or text type in a relational database. Commented Jan 26, 2017 at 14:55
  • Hi @arkascha you might want to look at dev.mysql.com/doc/refman/5.7/en/json.html Commented Jan 26, 2017 at 15:03
  • But yes, as arkascha said, JSON data type is not a thing in MariaDB yet, but MySQL supports that as RiggsFolly mentioned Commented Jan 26, 2017 at 15:06
  • "As of MySQL 5.7.8, MySQL supports a native JSON data type": dev.mysql.com/doc/refman/5.7/en/json.html Commented Jul 19, 2017 at 10:49

2 Answers 2

7

Solution is to convert json to string and save as text and re-convert to json after retrieving from database

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

Comments

0

Refer this ... this might help!

https://www.sitepoint.com/use-json-data-fields-mysql-databases/

P.S: Postgres have better features to store json data compared to mysql or mariaDB

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.