|o||The response is represented as a JSON object; each nested element or attribute is represented as a name/value property of the object.|
|o||Attributes are converted to String properties.|
|o||Attribute names are prefixed with @ so that they dont conflict with child elements of the same name.|
|o||Child elements are converted to Object properties.|
|o||Text values of tags are converted to $t properties.|
|o||If an element has a namespace alias, the alias and element are concatenated using $. For example, ns:element becomes ns$element.|
|o||XML version and encoding attributes are converted to attribute version and encoding of the root element, respectively.|
Creates a new XML::XML2JSON object.
It supports the following arguments:
An arraryref of element names that should be removed after calling the sanitize method. Children of the elements will be removed as well.
An arrayref of element names that should have their attributes and text content removed after calling the sanitize method. This leaves any children of the elements intact.
An arrayref of attribute names that should be removed after calling the sanitize method.
This is the name of the hash key that text content will be added to. This is $t by default.
If set to true, child elements that appear only once will be added to a one element array. If set to false, child elements that appear only once will be assesible as a hash value.
The default is false.
If set to true, output will be formatted to be easier to read whenever possible.
If set to true, will print warn messages to describe what it is doing.
Takes an XML string as input. Returns a string of sanitized JSON.
Calling this method is the same as:
my $Obj = $XML2JSON->xml2obj($XML); $XML2JSON->sanitize($Obj); my $JSON = $XML2JSON->obj2json($Obj);
This is an alias for convert.
Takes a perl data object as input. Return a string of equivalent JSON.
Takes an XML::LibXML::Document object as input. Returns an equivalent perl data structure.
Takes an xml string as input. Returns an equivalent perl data structure.
Takes a perl hashref as input. (You would normally pass this method the object returned by the xml2obj method.)
This method does not return anything. The object passed into it is directly modified.
Since JSON is often returned directly to a clients browser, there are cases where sensitive data is left in the response.
This method allows you to filter out content that you do not want to be included in the JSON.
This method uses the private_elements, empty_elements and private_attributes arguments which are set when calling the new method.
Takes a JSON string as input. Returns a string of equivalent XML.
Calling this method is the same as:
my $Obj = $Self->json2obj($JSON); my $XML = $Self->obj2xml($Obj);
Takes a json string as input. Returns an equivalent perl data structure.
Takes a perl data structure as input. (Must be a hashref.) Returns an XML::LibXML::Document object.
This method expects the object to be in the same format as would be returned by the xml2obj method.
o The root hashref may only have a single hashref key. That key will become the xml documents root. o A hashref will be converted to an element. o An arraysref of hashrefs will be converted into multiple child elements. Their names will be set to the name of the arrayrefs hash key. o If an attribute is prefixed by an @, the @ will be removed. o A hashkey named $t will be converted into text content for the current element.
o If a namespace alias has a $, it will be replaced using :. For example, ns$element becomes ns:element.
o The order of child elements and attributes cannot be determined.
This method takes the same arguments as obj2dom. Returns the XML as a string.
The order of child elements is not always preserved. This is because the conversion to json makes use of hashes in the resulting json.
Ken Prows - perl(AT)xev.net
Copyright (C) 2007-2008 Ken Prows
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|perl v5.20.3||XML::XML2JSON (3)||2012-01-22|