PHP solves the problem of json_decode parsing json string failure

The string required by json_decode is strict:

  1. Use UTF-8 encoding
  2. Cannot have a comma in the last element
  3. Single quotes cannot be used
  4. There cannot be \r,\t, please replace if there are

Encounter problems:

Some editors will add the BOM header by default when returning the json string, which will cause the parsing to fail.


$result = trim($result,chr(239).chr(187).chr(191));


Guess you like