Invalid JSON escape sequence in string

I am working with MySQL db, which encoded the polygon for google maps. When I try to return the request as json, jsonlint complains. I'm not sure why his complaints are, I really tried to escape the "}" in latlon, but still get the same error.

  Parse error on line 20:
 ... "latlon": "} ciuF | a | pNcUr@d @ es@
 ----------------------- ^
 Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

My json:

  {
     "maps": [
         {
             "group_id": "0",
             "user_id": "113",
             "group_name": "",
             "note": "",
             "field_id": "",
             "field_name": "West Pasture",
             "field_notes": "",
             "date_created": "12/31/2012",
             "acres": ""
         }
     ],
     "polygon": [
         {
             "polygon_id": "",
             "field_id": "1",
             "acres": "92",
             "latlon": "} ciuF | a | pNcUr@d @ es@fIHXaNtCn @UxCjMlApAfFuBpI} E \ ChJdEl@xAtE "
         }
     ]
 }
+4
source share
1 answer

The problem is that there is a slash before C that is not a valid escape sequence.

"} ciuF | | pNcUr @d @ es @fIHXaNtCn @UxCjMlApAfFuBpI} E \C hJdEl @xAtE"

 JSON.parse('"\\C"'); 

This will give you a syntax error as it tries to parse the \C string. If you need the literal value \ in your property value, you need to avoid it.

 "latlon": "}ciuF|a| pNcUr@d @ es@fIHXaNtCn @UxCjMlApAfFuBpI}E\\ ChJdEl@xAtE " 

Corresponding section from official grammar:

 string "" " chars " chars char char chars char any-Unicode-character- except-"-or-\-or- control-character \" \\ \/ \b \f \n \r \t \u four-hex-digits 
+4
source

All Articles