Requirement is like that a json object is send from postman and i need to receive it on a restcontroller and save that whole json object as it is to the mysql database Table Column(in one/single column) using spring boot.
{
"name" : "abc",
"address : "xyz"
}
assume the above json object is send from postman to a spring boot restcontroller. How can i save that json object in a column of a table .
MySQL supports JSON column types. https://dev.mysql.com/doc/refman/8.0/en/json.html
So, assuming you will be using json column type for your requirement, you can follow below articles. I was able to do this for postgres as well, works very well for me, the instructions are pretty straightforward.
https://vladmihalcea.com/how-to-map-json-objects-using-generic-hibernate-types/ https://vladmihalcea.com/java-map-json-jpa-hibernate/
There's no way. You can save it parsing the JSON to String ( Ex: JSON.stringify() ) and when you query the info , parse the string to JSON (Ex: JSON.parse() )
JSON.stringify: https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/JSON/stringify
JSON.parse: https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/JSON/parse
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With