MajorLeagueBaseball / freemarker-json

A Freemarker macro for outputting JSON.
21 stars 14 forks source link

Apostrophe Incorrectly Escaped #3

Open Jimmerz28 opened 7 years ago

Jimmerz28 commented 7 years ago

Currently, it looks like any strings apostrophes are getting escaped with a backslash as they are being escaped with ?js_string instead of ?json_string which is leading to invalid JSON being generated.

http://freemarker.org/docs/ref_builtins_string.html#ref_builtin_json_string

For example:

[#assign something = { brain: "Some strings' string" } ]

<script type="application/json" id="subnavigationProps">
    [@json.stringify something /]
</script>

Generates:

<script type="application/json">
    {"brain":"Some string\'s string"}
</script>

Which is invalid JSON.

If this project is still maintained let me know and I can create a PR.