我在Android中有这个结构:
HttpPost post = new HttpPost(url);
mjson.put("receiveOrderId", receiveOrderId);
mjson.put("packageId", packageId);
mjson.put("partNumber", partNumber);
mjson.put("qty", qty);
mjson.put("serial", serial);
mjson.put("locationId", locationId);
json.put("version", "6");
json.put("token", token);
json.put("data", mjson);
post.setHeader("json", json.toString());
StringEntity se = new StringEntity(json.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,
"application/json"));
post.setEntity(se);
response = client.execute(post);
而且我需要在php中解码,如何访问“partNumber”或“qty”的值?
尝试这种方式,但它不起作用:
$data = file_get_contents('php://input');
$json = json_decode($data);
$version = $json->{'version'};
$token = $json->{'token'};
$receiveOrderId = $json->{'receiveOrderId'};
$packageId = $json->{'packageId'};
$partNumber = $json->{'partNumber'};
$qty = $json->{'qty'};
$serial = $json->{'serial'};
$locationId = $json->{'locationId'};
*抱歉我的英语不好,我来自墨西哥。