How to store JSON data using GORM Database for MySQL?

I have a dynamic object that needs to be saved, whose definition and values ​​change based on different users. You can think of them as dynamic forms that are first defined by the administrator and then filled in by different users.

I don't have a MySQL alternative for my project, so no db-free schema is out of the question.

I could do it using regular relational model stores and there are values ​​on multiple tables, but that was too clunky. So I decided to store these dynamic objects as JSON in a MySQL table.

Is this a good approach? If you can't suggest any correct alternatives?

Anyway I'm having a problem retrieving an object from JSON from a database using Grails. This is my example class where definition is the field where the JSON needs to be stored.

String subJobType
String definition

static constraints = {
    definition nullable: false
}

static mapping = {
    definition sqlType: 'MEDIUMTEXT',type: 'text'
}

      

I can only get the definition field as a string, but I want to return an object instead.

I could get all the objects first and then convert the entire definition field of each object to JSON, but that doesn't seem like a good idea.

+3
json mysql grails gorm


source to share


No one has answered this question yet

Check out similar questions:

2858
How can I print JSON in a shell script?
2568
Should I be using the datetime or timestamp datatype in MySQL?
2480
How do I send JSON data using Curl from terminal / command line to Test Spring REST?
1817
How to customize Microsoft JSON date?
1542
How can I print JSON using JavaScript?
1290
How do I get a list of user accounts using the command line in MySQL?
1112
What MySQL data type is used to store boolean values
1086
How to connect to MySQL database in Python?
1065
Link. What does this error mean in PHP?
379
How do I add indexes to MySQL tables?



All Articles
Loading...
X
Show
Funny
Dev
Pics