user401000
user401000

Reputation: 255

How to convert JSON to string

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

Answers (2)

VolkerK
VolkerK

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

Ramesh Seera
Ramesh Seera

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

Related Questions