Skip to content

Escaped forward slash in JSON throws exception #2

@davecraig

Description

@davecraig

If in my Android app I generate JSON from a JSONObject then forward slashes are always escaped, and double quotes are used as per the JSON spec e.g.

{
  "country": "Alba \/ Scotland",
  "house_number": "48",
  "city": "Glasgow",
  "road": "Station Road",
  "neighbourhood": "Milngavie",
  "country_code": "GB",
  "postcode": "G62 8AB",
  "county": "East Dunbartonshire",
  "state": "Scotland"
}

This throws an exception when passing it into AndroidAddressFormatter format:

Caused by: com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.MarkedYAMLException: while scanning a double-quoted scalar
in 'reader', line 1, column 12:
{"country":"Alba \/ Scotland","house_number ... 
            ^
found unknown escape character /(47)
in 'reader', line 1, column 19:
{"country":"Alba \/ Scotland","house_number":"48", ...
                  ^

If I replace the "\/" with "/" then there's no issue, so I have a workaround for now, but it's not clear to me how the JSON->YAML parsing is designed to work in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions