.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" 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 .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Search::Elasticsearch::Role::Serializer::JSON 3pm" .TH Search::Elasticsearch::Role::Serializer::JSON 3pm "2018-05-17" "perl v5.26.2" "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" Search::Elasticsearch::Role::Serializer::JSON \- A Serializer role for JSON modules .SH "VERSION" .IX Header "VERSION" version 6.00 .SH "DESCRIPTION" .IX Header "DESCRIPTION" This role encodes Perl data structures into \s-1JSON\s0 strings, and decodes \s-1JSON\s0 strings into Perl data structures. .SH "METHODS" .IX Header "METHODS" .ie n .SS """encode()""" .el .SS "\f(CWencode()\fP" .IX Subsection "encode()" .Vb 2 \& $bytes = $serializer\->encode($ref); \& $bytes = $serializer\->encode($str); .Ve .PP The \*(L"\fIencode()\fR\*(R" method converts array and hash refs into their \s-1JSON\s0 equivalents. If a string is passed in, it is returned as the \s-1UTF8\s0 encoded version of itself. The empty string and \f(CW\*(C`undef\*(C'\fR are returned as is. .ie n .SS """encode_pretty()""" .el .SS "\f(CWencode_pretty()\fP" .IX Subsection "encode_pretty()" .Vb 2 \& $bytes = $serializer\->encode_pretty($ref); \& $bytes = $serializer\->encode_pretty($str); .Ve .PP Works exactly as \*(L"\fIencode()\fR\*(R" but the \s-1JSON\s0 output is pretty-printed. .ie n .SS """encode_bulk()""" .el .SS "\f(CWencode_bulk()\fP" .IX Subsection "encode_bulk()" .Vb 2 \& $bytes = $serializer\->encode_bulk([\e%hash,\e%hash,...]); \& $bytes = $serializer\->encode_bulk([$str,$str,...]); .Ve .PP The \*(L"\fIencode_bulk()\fR\*(R" method expects an array ref of hashes or strings. Each hash or string is processed by \*(L"\fIencode()\fR\*(R" then joined together by newline characters, with a final newline character appended to the end. This is the special \s-1JSON\s0 format used for bulk requests. .ie n .SS """decode()""" .el .SS "\f(CWdecode()\fP" .IX Subsection "decode()" .Vb 2 \& $var = $serializer\->decode($json_bytes); \& $str = $serializer\->decode($bytes); .Ve .PP If the passed in value looks like \s-1JSON\s0 (ie starts with a \f(CW\*(C`{\*(C'\fR or \f(CW\*(C`[\*(C'\fR character), then it is decoded from \s-1JSON,\s0 otherwise it is returned as the \s-1UTF8\s0 decoded version of itself. The empty string and \f(CW\*(C`undef\*(C'\fR are returned as is. .SH "AUTHOR" .IX Header "AUTHOR" Clinton Gormley .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is Copyright (c) 2017 by Elasticsearch \s-1BV.\s0 .PP This is free software, licensed under: .PP .Vb 1 \& The Apache License, Version 2.0, January 2004 .Ve