rails_noob
rails_noob

Reputation: 311

convert POST array to json format

How can I convert php's POST variable to json format?

Upvotes: 16

Views: 35967

Answers (2)

Code Magician
Code Magician

Reputation: 23972

If this is entirely in php, and you simply want to convert the data in $_POST to JSON, you can do so like this:

$json = json_encode($_POST);

Using php's built-in function json_encode (doc)

If this is not what you want to do, please be more specific with your question.

Upvotes: 49

Peter
Peter

Reputation: 16923

json_encode($_POST);

Upvotes: 3

Related Questions