How to deal with backslashes in json strings php

后端 未结 5 771
慢半拍i
慢半拍i 2020-11-30 12:26

There appears to be an oddity with json_encode and/or json_decode when attempting decode a string that was produced by json_encode:

    $object = new stdClas         


        
5条回答
  •  Happy的楠姐
    2020-11-30 13:06

    Thats because PHP is converting the double slashes into a single slash before passing it to json_decode. You will need to either escape the double slashes (a pain I know) or construct the object manually.

    http://php.net/manual/en/language.types.string.php#language.types.string.syntax.single

提交回复
热议问题