mholt / json-to-go

Translates JSON into a Go type in your browser instantly (original)
https://mholt.github.io/json-to-go/
MIT License
4.48k stars 473 forks source link

value-strings containing <x,html tags> break parsing #109

Closed dumpster-of-things closed 2 years ago

dumpster-of-things commented 2 years ago

Issue easily reproduced using this JSON response example from Google: https://developers.google.com/maps/documentation/places/web-service/details#PlaceDetailsResponses

I've had issues with json-2-go breaking because of trailing commas and unecessary newlines/whitespace; and so I first copied the example JSON into my editor(sublime) in order to clean it up a bit... After hours of manually trying things like escaping the inner xml quotation marks - for example: '<span class=\"nested xml Key\">nested xml Value</span>, ... , ... </span>'

mholt commented 2 years ago

You're welcome, glaed you find the project useful!

Unfortunately, that input is not valid JSON. (I do find it bizarre that an official Google API is returning invalid JSON.) Trailing commas are not allowed in JSON, nor are strings that are delimited by single-quotes; strings have to use double quotes.

Here is the grammar/spec: https://www.json.org/json-en.html

dumpster-of-things commented 2 years ago

Well heyll. In addition to your wonderful project, I also appreciate you- for turning my pretension into a learning opportunity (:

On Wed, Apr 27, 2022 at 12:21 PM Matt Holt @.***> wrote:

Closed #109 https://github.com/mholt/json-to-go/issues/109.

— Reply to this email directly, view it on GitHub https://github.com/mholt/json-to-go/issues/109#event-6508416270, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJVHKS47HSTS5VL4YRYEQK3VHFSQTANCNFSM5UN6QVYA . You are receiving this because you authored the thread.Message ID: @.***>