Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi there monks,
I'm looking for a module on CPAN that can convert Javascript code snippets to JSON, apart from also doing the more common data-structure to JSON conversion. I've tried JSON::XS, ::Syck, ::PP and neither seem to be able to do this:
But it usually converts it to: ...handler: "function(...)"
I'm looking for a module on CPAN that can convert Javascript code snippets to JSON, apart from also doing the more common data-structure to JSON conversion. I've tried JSON::XS, ::Syck, ::PP and neither seem to be able to do this:
And the output should look like this:my $data = { age=>18, handler=>\"function(){ alert('hello, worldly') }" }; my $json = encode_json( $data )
{ age: 18, handler: function(){ ... } }
But it usually converts it to: ...handler: "function(...)"
I know I've seen something that can do that somewhere. I think the usual implementation would use scalar references (ie \"function(){ }") to achieve this. But none of the regular JSON modules seem to accept it.
Any clues?
Thanks,
miguel
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Javascript in your JSON
by derby (Abbot) on Apr 08, 2009 at 12:09 UTC | |
by Anonymous Monk on Apr 08, 2009 at 19:08 UTC | |
by ikegami (Patriarch) on Apr 08, 2009 at 19:14 UTC | |
by derby (Abbot) on Apr 08, 2009 at 19:30 UTC | |
Re: Javascript in your JSON
by Anonymous Monk on Apr 08, 2009 at 10:02 UTC | |
Re: Javascript in your JSON
by Anonymous Monk on Apr 09, 2009 at 09:46 UTC |
Back to
Seekers of Perl Wisdom