A function I found online: {code...} a function I found online:
Function is_json ($ string) {json_decode ($ string); return (json_last_error () = JSON_ERROR_NONE);} $ str = '{id: 23, name: "test"} '; $ str = "{'id': 23, 'name': 'test'}"; why isn't PHP7 in legal json format ?? Is there a reliable way ??
Reply content:
A function I found online:
Function is_json ($ string) {json_decode ($ string); return (json_last_error () = JSON_ERROR_NONE);} $ str = '{id: 23, name: "test"} '; $ str = "{'id': 23, 'name': 'test'}"; why isn't PHP7 in legal json format ?? Is there a reliable way ??
JSON format. both key and value must be double quotation marks ......
return json_encode($json)!==false
PHP7 adopts more strict JSON rules. single quotes can no longer be used for reference and field names.
Var arr = {id: 23, name: 'test'}; // The key name does not need to be enclosed in quotation marks. The value is enclosed in single quotation marks. in JS, such writing is legal alert (JSON. stringify (arr); // The valid JSON string should be after stringify {"id": 23, "name": "test "}