0

The accepted answer to "How to convert Perl objects into JSON and vice versa" says that the conversion is hairy.

Does anyone actually use JSON for deserialization of nested blessed objects? How?

Community
  • 1
  • 1
sds
  • 58,617
  • 29
  • 161
  • 278
  • 2
    Do you have a concrete example ? What is your definition of "Blessing" in the `R` context. – dickoa Jul 09 '13 at 21:20
  • @dickoa: not `R`! `Perl`! – sds Jul 10 '13 at 01:31
  • When I commented this question the `r` tag was in this question and no `perl` tag. I was confused but now everything make sense (you corrected it). – dickoa Jul 10 '13 at 05:26

1 Answers1

0

Use JSYNC.

perl -Moose=Foo -MJSYNC -e'
    has "attr", is => "rw", isa => "HashRef[HashRef]", default => sub { { 0 => { 1 => { 3 => 4} } } };
    print JSYNC::dump(Foo->new)
'
{"!":"!perl/hash:Foo","attr":{"0":{"1":{"3":"4"}}}}
daxim
  • 39,270
  • 4
  • 65
  • 132
  • JSYNC does not appear to be stable enough (not even in ubuntu!) – sds Jul 10 '13 at 14:41
  • You have a strange definition of stable. – daxim Jul 11 '13 at 04:04
  • Strange or not - I have given up on cpan and I need my code to work on Ubuntu and CentOS, so things which cannot be installed with aptitude and yum are beyond my reach. – sds Jul 11 '13 at 04:26
  • That's something different now. You should learn how to make your own package, it appears you haven't done so yet. Running `dh-make-perl` or `cpanspec` isn't rocket surgery. – daxim Jul 11 '13 at 05:09