force json_encode to create strings

后端 未结 4 1814
感动是毒
感动是毒 2020-12-21 14:51

I have to json_encode a PHP array to a JavaScript array. Unfortunately the jQuery library I am using will not properly process that array if it contains ints instead of stri

4条回答
  •  再見小時候
    2020-12-21 15:18

    json_decode() can convert large integers to strings, if you specify a flag in the function call:

    $array = json_decode($json, true, 512, JSON_BIGINT_AS_STRING)
    

提交回复
热议问题