I want to use Perl script that gets the JSON data and converts it into XML file. How can I do that in Perl?
+9
A:
Install: XML::XML2JSON with
sudo cpan XML::XML2JSON
and then try:
use XML::XML2JSON;
my $JSON = '{"entry":{"name":"Douglas Crockford","phone":"555 123 456"}}';
my $XML2JSON = XML::XML2JSON->new();
my $Obj = $XML2JSON->json2obj($JSON);
my $XML = $XML2JSON->obj2xml($Obj);
print $XML;
Jonas Elfström
2009-10-09 10:42:11
+8
A:
use JSON;
my $json_string = '................';
my $deserialized = from_json( $json_string );
That's all - your JSON data is parsed and stored in $deserialized.
depesz
2009-10-09 11:13:53
If performance is at all a concern, also install JSON::XS (JSON will use it if it's there...no code changes needed).
ysth
2009-10-09 16:08:09