json_encode json data php code example
Example 1: php return json data
header('Content-Type: application/json');
$colors = array("red","blue","green");
echo json_encode($colors);
Example 2: post json array data curl
curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT -d '{"tags":["tag1","tag2"],"question":"Which band?","answers":[{"id":"a0","answer":"Answer1"},{"id":"a1","answer":"answer2"}]}' http://example.com/service`