Json GetEncoded Example

This example shows two different ways to get quotes in a Json on the client. Using entities (") you need to use the GetEncoded viper, or the quotes will be decoded by the renderengine, leaving an invalid Json. Using escaping (\"), the output is indepent of the xml decoding done by the renderengine.

Smartsite SXML CopyCode image Copy Code
<se:json localid="test">
    {
        "encoded":"&quot;test&quot;",
        "escaped":"\"test\""
    }
</se:json>

{scope.test.get()}
{scope.test.getencoded()}
{scope.test.getvalue(escaped)}
{scope.test.getencodedvalue(encoded)}
Example Result CopyCode image Copy Code
{"encoded":""test"","escaped":"\"test\""}
{"encoded":"&quot;test&quot;","escaped":"\"test\""}
"test"
&quot;test&quot;