[
https://issues.apache.org/jira/browse/FREEMARKER-231?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17941052#comment-17941052
]
Dániel Dékány commented on FREEMARKER-231:
------------------------------------------
FreeMarker won't escape like that by default, because it doesn't know if the
value is inserted at a position that happens to be inside a JSON string literal
in the output. But since you do know that that's desired in the kind of
template that you have, you can define a {{MarkupOutputFormat}} to do JSON
string literal escaping everywhere automatically.
> Config to support [?json_string] globally
> ------------------------------------------
>
> Key: FREEMARKER-231
> URL: https://issues.apache.org/jira/browse/FREEMARKER-231
> Project: Apache Freemarker
> Issue Type: Bug
> Affects Versions: 2.3.30
> Reporter: Lahiru Madushanka
> Priority: Major
>
> Hi Devs,
> I'm creating this issue on behalf of the WSO2 Micro Integrator team. We are
> using Freemarker in our product to transform user payloads and are quite
> happy with the functionalities and ease of use.
> Recently, we got an issue from our customer saying the String values are
> getting escaped in a JSON payload
> 25.09\t& get changed to 25.09[0x09]&
> Sample configuration
>
> {code:java}
> "ResponsePayload": { "result": { "Table": { "FAULT_DESC":
> "${ctx.CEPFaultDesc}" } }
> {code}
>
> We later inject the ctx.CEPFaultDesc value to freemarker.
>
> Upon doing some research, we asked the customer to use the following config
> with ?json_string, which resolved the issue
>
> {code:java}
> "ResponsePayload": { "result": { "Table": { "FAULT_DESC":
> "${ctx.CEPFaultDesc?json_string}" } }{code}
>
>
> But, the problem is we feel like it's wrong to escape the string values. We
> are creating this issue to check if there's a way to apply this config change
> globally (not in individual fields). If not, will it be considered in a
> future release?
>
> We are using version 2.3.30
>
> Thanks in advance.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)