如何从android应用程序接收作为参数传递的json数据?

I used to decode a json string stored in a variable. Now i've come across a situation where a php file is passed a set of json data.

I'm not aware of how to get the data and then decode it to php array.

please do not give answers like

$variable = '{ "data1" : "value1" }';

I've used this before.

//Edit

Also I'm not asking how to encode a php array to json.

Thanks.

You should use the PHP function json_encode

<?php
$var = array('a' => 1, 'b' => 2);

echo json_encode($var);
?>

You can Decode in same way by same way json_decode

$var= '{"car": 5}';

$obj = json_decode($var);
echo $obj->{'car'};