How you actually showing in site ? Html code? Can I see it? May be you are getting the json fields in a string variable.
Create model with json field with API
Hey guys,
I have a model wich has a json field inside the migration and I´ve build a crud-controller for the api.
Now I want to create a new model via the api, but I have problem creating it.
This would be the document-body
{
"field1":"value1",
"field2" : {
"field3" : {
"field4":"value4"
}
}
}
When I am trying to post it to my site, I am getting an error which says: "Array to string conversion". What am I doing wrong?
Is there anything special I must look around to get it working?
field2 is JSON inside the migration
Best regards!
I found the solution, in my model I must add the protected casts array which contains the cast of the field to the desired value (in this case: array).
Please or to participate in this conversation.