georust / geozero

Zero-Copy reading and writing of geospatial data.
Apache License 2.0
323 stars 30 forks source link

geojson: escape quotes in written property name/values #87

Closed brendanashworth closed 1 year ago

brendanashworth commented 1 year ago

As far as I can tell, serde-json automatically unescapes input, so this change is not needed on the reader.

Before this would output invalid JSON with random unescaped quotes in the property fields. Test fails before, now passes.

brendanashworth commented 1 year ago

Just changed the code as you suggested, thanks for reviewing @pka

brendanashworth commented 1 year ago

Perhaps annoyingly, I didn't realize that there's more characters that need to be escaped in valid JSON, at least according to jq:

parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line ..., column ...

In JSON the only characters you must escape are \, ", and control codes

This blog post seems to have some interesting suggestions on escaping things quickly so I'm going to try out an implementation, will follow up with another PR probably