SyntaxError: JSON.parse: expected double-quoted property name at line 4 column 13 of the JSON data的解决办法

. 1 ? < PHP
 2      $ UPhone = $ _POST [ "USERPHONE" ];
 . 3      IF ( $ UPhone == "139") { // phone number is unavailable 
. 4          echo ' {
 . 5              "Status": 0,
 . 6              "Message": "phone number is not available",
 . 7              } ' ;
 . 8      } the else { // the phone number is available 
. 9          echo ' {
 10              "Status":. 1,
 . 11              "Message": {
 12 is                  "
tips ":" phone number available ", 13                 "phoneform": "China Telecom",
 14              }
 15          } ' ;
 16      }
 17 >?

Run the code above this error will be reported: SyntaxError: JSON.parse: expected double- quoted property name at line 4 column 13 of the JSON data. The reason is that format error occurred when array assignment, the last property should not be a comma. As :( "the Message": "phone number is not available") and ( "phoneform": "China Telecom"), the back can not add any comments. Into this example ( "message": "phone number is not available" // comment) is also given: SyntaxError: the JSON.parse: expected ',' or '}' After AT Line Object Property value in column 32. 3 of the JSON The data

Code can be changed as follows:

. 1 ? < PHP
 2      $ UPhone = $ _POST [ "USERPHONE" ];
 . 3      IF ( $ UPhone == "139") { // phone number is unavailable 
. 4          echo ' {
 . 5              "Status": 0,
 . 6              "Message": "phone number is not available" 
 . 7              } ' ;
 . 8      } the else { // the phone number is available 
. 9          echo ' {
 10              "Status":. 1,
 . 11              "Message": {
 12 is                  "
tips ":" phone number available ", 13                 "phoneform": "China Telecom" 
 14              }
 15          } ' ;
 16      }
 17 >?

 

Guess you like

Origin www.cnblogs.com/banyouxia/p/10945498.html