MKGeoJSONDecoder can't parse escaped Double-Quote characters

Originator:yantramanav
Number:rdar://FB7670149 Date Originated:2020-04-20
Status:Open Resolved:
Product:MapKit Product Version:13.4
Classification: Reproducible:
 
Please provide a descriptive title for your feedback:
MKGeoJSONDecoder can't parse escaped Double-Quote characters

Which area are you seeing an issue with?
MapKit

Please describe the issue and what steps we can take to reproduce it:
When parsing valid GeoJSON data containing escaped double-quotes, the MKGeoJSONDecoder fails with error.

Steps to reproduce:
1. Download and copy the GeoJSON from the Berlin city API server into a String:  
https://www.berlin.de/sen/web/service/liefer-und-abholdienste/index.php/index/all.gjson?q=&plz=10117&art=B%C3%BCrobedarf&ipp=20&page=1 
OR use the following GeoJSON data

{
            "features": [
                {
                    "geometry": {
                        "coordinates": [
                            13.38678,
                            52.52548
                        ],
                        "type": "Point"
                    },
                    "properties": {
                        "description": " \" text in double quotes \" ",
                        "href": "/sen/web/service/liefer-und-abholdienste/index.php/detail/1848",
                        "id": "/sen/web/service/liefer-und-abholdienste/index.php/detail/1848",
                        "title": "1848"
                    },
                    "type": "Feature"
                }
            ],
            "type": "FeatureCollection"
}

2. Create a Data object from the string using .utf8 format
3. Create a MKGeoJSONDecoder object
4. Try and parse the data using  `try decoder.decode(data)` in a do..catch block
5. The catch block will report an error saying: “The data couldn’t be read because it isn’t in the correct format.”

If we change the “description” string and remove the escaped double-quotes `“\`, the MKGeoJSONDecoder decodes the data without issue.

The attached practice.playground should show the error when the program is run.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!