.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .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. | will give a .\" real vertical bar. \*(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-|\(bv\*(Tr .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" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "JSON::Any 3" .TH JSON::Any 3 "2007-10-22" "perl v5.8.8" "User Contributed Perl Documentation" .SH "NAME" JSON::Any \- Wrapper Class for the various JSON classes. .SH "VERSION" .IX Header "VERSION" Version 1.12 .SH "SYNOPSIS" .IX Header "SYNOPSIS" This module will provide a coherent \s-1API\s0 to bring together the various \s-1JSON\s0 modules currently on \s-1CPAN\s0. This module will allow you to code to any \s-1JSON\s0 \s-1API\s0 and have it work regardless of which \s-1JSON\s0 module is actually installed. .PP .Vb 1 \& use JSON::Any; .Ve .PP .Vb 1 \& my $j = JSON::Any->new; .Ve .PP .Vb 2 \& $json = $j->objToJson({foo=>'bar', baz=>'quux'}); \& $obj = $j->jsonToObj($json); .Ve .PP or .PP .Vb 2 \& $json = $j->encode({foo=>'bar', baz=>'quux'}); \& $obj = $j->decode($json); .Ve .PP or .PP .Vb 2 \& $json = $j->Dump({foo=>'bar', baz=>'quux'}); \& $obj = $j->Load($json); .Ve .PP or .PP .Vb 2 \& $json = $j->to_json({foo=>'bar', baz=>'quux'}); \& $obj = $j->from_json($json); .Ve .PP or without creating an object: .PP .Vb 2 \& $json = JSON::Any->objToJson({foo=>'bar', baz=>'quux'}); \& $obj = JSON::Any->jsonToObj($json); .Ve .PP On load, JSON::Any will find a valid \s-1JSON\s0 module in your \f(CW@INC\fR by looking for them in this order: .PP .Vb 4 \& JSON::XS \& JSON \& JSON::DWIW \& JSON::Syck .Ve .PP And loading the first one it finds. .PP You may change the order by specifying it on the \f(CW\*(C`use JSON::Any\*(C'\fR line: .PP .Vb 1 \& use JSON::Any qw(DWIW Syck XS JSON); .Ve .PP Specifying an order that is missing one of the modules will prevent that module from being used: .PP .Vb 1 \& use JSON::Any qw(DWIW XS JSON); .Ve .PP This will check in that order, and will never attempt to load JSON::Syck. This can also be set via the \f(CW$ENV\fR{\s-1JSON_ANY_ORDER\s0} environment variable. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .ie n .IP """new""" 4 .el .IP "\f(CWnew\fR" 4 .IX Item "new" Will take any of the parameters for the underlying system and pass them through. However these values don't map between \s-1JSON\s0 modules, so, from a portability standpoint this is really only helpful for those paramters that happen to have the same name. This will be addressed in a future release. .Sp The one parameter that is universally supported (to the extent that is supported by the underlying \s-1JSON\s0 modules) is \f(CW\*(C`utf8\*(C'\fR. When this parameter is enabled all resulting \s-1JSON\s0 will be marked as unicode, and all unicode strings in the input data structure will be preserved as such. .Sp The actual output will vary, for example \s-1JSON\s0 will encode and decode unicode chars (the resulting \s-1JSON\s0 is not unicode) wheras \s-1JSON::XS\s0 will emit unicode \&\s-1JSON\s0. .ie n .IP """handlerType""" 4 .el .IP "\f(CWhandlerType\fR" 4 .IX Item "handlerType" Takes no arguments, returns a string indicating which \s-1JSON\s0 Module is in use. .ie n .IP """handler""" 4 .el .IP "\f(CWhandler\fR" 4 .IX Item "handler" Takes no arguments, if called on an object returns the internal JSON::* object in use. Otherwise returns the JSON::* package we are using for class methods. .ie n .IP """objToJson""" 4 .el .IP "\f(CWobjToJson\fR" 4 .IX Item "objToJson" Takes a single argument, a hashref to be converted into \s-1JSON\s0. It returns the \s-1JSON\s0 text in a scalar. .ie n .IP """to_json""" 4 .el .IP "\f(CWto_json\fR" 4 .IX Item "to_json" .PD 0 .ie n .IP """Dump""" 4 .el .IP "\f(CWDump\fR" 4 .IX Item "Dump" .ie n .IP """encode""" 4 .el .IP "\f(CWencode\fR" 4 .IX Item "encode" .PD Aliases for objToJson, can be used interchangeably, regardless of the underlying \s-1JSON\s0 module. .ie n .IP """jsonToObj""" 4 .el .IP "\f(CWjsonToObj\fR" 4 .IX Item "jsonToObj" Takes a single argument, a string of \s-1JSON\s0 text to be converted back into a hashref. .ie n .IP """from_json""" 4 .el .IP "\f(CWfrom_json\fR" 4 .IX Item "from_json" .PD 0 .ie n .IP """Load""" 4 .el .IP "\f(CWLoad\fR" 4 .IX Item "Load" .ie n .IP """decode""" 4 .el .IP "\f(CWdecode\fR" 4 .IX Item "decode" .PD Aliases for jsonToObj, can be used interchangeably, regardless of the underlying \s-1JSON\s0 module. .SH "AUTHOR" .IX Header "AUTHOR" Chris Thompson, \f(CW\*(C`\*(C'\fR Chris Prather, \f(CW\*(C`\*(C'\fR .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-json\-any at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" This module came about after discussions on irc.perl.org about the fact that there were now six separate \s-1JSON\s0 perl modules with different interfaces. .PP In the spirit of Class::Any, JSON::Any was created with the considerable help of Matt 'mst' Trout. .PP San Dimas High School Football Rules! .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2007 Chris Thompson, some rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.