How to deal with backslashes in json strings php

后端 未结 5 773
慢半拍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条回答
  •  旧巷少年郎
    2020-11-30 13:20

    You can just use the stripslashes function to strip the dashes and it will work tested

      $yetAnotherObject = json_decode(stripslashes('{"namespace":"myCompany\\package\\subpackage"}'));
    

提交回复
热议问题