Reputation: 255
How do I convert a JSON object to a string?
I want to insert a JSON object into a mysql DB.
Upvotes: 22
Views: 147471
Reputation: 96159
You might be interested in json_encode().
On the other hand if you already got something json encoded then it already is a string and you can simply store it as-is in the database.
Upvotes: 29
Reputation: 191
JSON itself is a string. People use json_encode() and json_decode() to convert objects/arrays of PHP to string and back to objects/arrays.
Upvotes: 11