.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Template::Plugin::JSON::Escape 3pm" .TH Template::Plugin::JSON::Escape 3pm "2021-01-03" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Template::Plugin::JSON::Escape \- Adds a .json vmethod and a json filter. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& [% USE JSON.Escape( pretty => 1 ) %]; \& \& \& \& or read in JSON \& \& [% USE JSON.Escape %] \& [% data = JSON.Escape.json_decode(json) %] \& [% data.thing %] .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This plugin allows you to embed \s-1JSON\s0 strings in \s-1HTML.\s0 In the output, special characters such as \f(CW\*(C`<\*(C'\fR and \f(CW\*(C`&\*(C'\fR are escaped as \f(CW\*(C`\euxxxx\*(C'\fR to prevent \s-1XSS\s0 attacks. .PP It also provides decoding function to keep compatibility with Template::Plugin::JSON. .SH "FEATURES" .IX Header "FEATURES" .SS "\s-1USE JSON\s0.Escape" .IX Subsection "USE JSON.Escape" Any options on the \s-1USE\s0 line are passed through to the \s-1JSON\s0 object, much like \*(L"to_json\*(R" in \s-1JSON\s0. .SS "json vmethod" .IX Subsection "json vmethod" A \f(CW\*(C`.json\*(C'\fR vmethod converts scalars, arrays and hashes into corresponding \s-1JSON\s0 strings. .PP .Vb 1 \& [% json_stuct = { foo => 42, bar => [ 1, 2, 3 ] } %] \& \& \& \& .Ve .SS "json filter" .IX Subsection "json filter" A \f(CW\*(C`json\*(C'\fR filter escapes \f(CW\*(C`<\*(C'\fR, \f(CW\*(C`>\*(C'\fR, \f(CW\*(C`&\*(C'\fR, \f(CW\*(C`+\*(C'\fR, \f(CW\*(C`U+2028\*(C'\fR and \f(CW\*(C`U+2029\*(C'\fR as \f(CW\*(C`\euxxxx\*(C'\fR. In the attribute, you may just use an \f(CW\*(C`html\*(C'\fR filter. .PP .Vb 1 \& [% json_string = \*(Aq{ "foo": 42, "bar": [ 1, 2, 3 ] }\*(Aq %] \& \& \& \& .Ve .SS "json_decode method" .IX Subsection "json_decode method" A \f(CW\*(C`json_decode\*(C'\fR method allow you to convert from a \s-1JSON\s0 string into a corresponding data structure. .PP .Vb 2 \& [% SET json_struct = JSON.Escape.json_decode(json_string) %] \& [% json_struct.foo | html %] .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Template::Plugin::JSON, \s-1JSON\s0, Template::Plugin .SH "VERSION CONTROL" .IX Header "VERSION CONTROL" .SH "AUTHOR" .IX Header "AUTHOR" nanto_vi (\s-1TOYAMA\s0 Nao) .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright (c) 2011 nanto_vi (\s-1TOYAMA\s0 Nao). .PP Copyright (c) 2006, 2008 Infinity Interactive, Yuval Kogman. .PP Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \*(L"Software\*(R"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: .PP The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. .PP \&\s-1THE SOFTWARE IS PROVIDED \*(L"AS IS\*(R", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\s0