I have a json object in my JavaScript file containing
"qs": {}
which when I store it in the database, becomes:
[object Object]
At other times the same object looks like this:
"qs":{"id": "stackoverflow"}
or this:
"qs":{"id": "stackoverflow", "location": "USA"}
But regardless of how many elements the array contains, I want to store it in a single database table field – so I need to compress it into a readable string.
What’s the best way to do this with a field that may be null at certain times (as above)?
You probably want to use stringify to convert the object to a string.
Also
{}is not null, it is an empty object."qs" : nullis null.