dsj2222222 2015-07-08 09:51
浏览 65

当字符串包含“&”符号时,Json_decode抛出一个空数组

I have a problem with the json_decode() when passed string contain "&". When mobile app send a request as a post containing this type of a UTF encoded string:

[
  {
    "mobile": [
      "123456"
    ],
    "full_name": [
      "Bride&Groom"
    ]
  }

json_decode() a null array. This happens when only send the request through the mobile end. specific scenario? We are using Laravel 5.

Request taken like this $friendDetails = $request->friend then pass the variable through json_decode

$decodedFriend = json_decode($friendDetails ,true);

As headers we are using Oauth and header values are like this.

Authorization Bearer <token>

Content type is application form data

Thanks in advance

  • 写回答

1条回答 默认 最新

  • dongsong1911 2015-07-08 09:55
    关注

    I just tried with json_decode function and the string you gave as example is perfectly decoded to:

    object(stdClass)#1 (2) {
      ["mobile"]=>
      array(1) {
        [0]=>
        string(6) "123456"
      }
      ["full_name"]=>
      array(1) {
        [0]=>
        string(11) "Bride&Groom"
      }
    }
    

    Consider adding a MCVE

    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探