简体   繁体   中英

POSTed JSON from Android can't decode in PHP

i POST a JSON-String from an Android Application to a Webserver. There i want to decode the String into JSON and save the data into a database. But here is the Problem.

I read out the POST-Variable:

$json = $_POST['json'];

This brings me:

{"user":"Bob"}

Then i decode the json:

$decoded = json_decode($json, true);

There i get NULL!

BUT, when i create a String in PHP like:

$json = '{"user":"Bob"}';

and decode, it works?! But why? Where is the difference? Hope everyone can help me! :-/

Thanks a lot!

Thomas

您可能会以字符串形式发送json数据,只是发送它,因为在传递json数据时不要使用(')(")倒置逗号。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM