Re: [Boston.pm] perl data to/from JSON?

"Greg London" <email-2Ro/Dj86MvDSUeElwK9/[email protected]> Wed, 30 Jan 2019 11:36:17 -0500
Newsgroups gmane.comp.lang.perl.perl-mongers.boston
Message-ID <[email protected]>
Wrote a longer email and my browser reset when I hit send.
Shorter version:

Thanks to everyone for all the help and links.
I've bookmarked links and have been looking through them.
We've started writing the scripts and so far so good.
The proof will be when the scripts start talking back and
forth through JSON.  But all your help got us up and running.

Thanks again,
Greg



On Fri, January 25, 2019 3:47 pm, Greg London wrote:
> This is a work-related issue, so certain decisions are out of my control.
>  Also, I know only rudimentary python, and I know absolutely nothing
> about JSON, so, this whole thing may be complete garbage for reasons I'm
> unaware of. That said:
>
> We have a number of perl and python scripts and we are looking to share
> data between them. It was decided that we use a JSON file format to store
> data and then have all the scripts read/write this format so it wouldn't
> matter if the script was python or perl.
>
> basically I want to do this:
>
> my $my_complex_data = [ {key1=>data1,key2=>data2}, [ {}, {key=>[] } ]];
> use Storable qw(nstore dclone retrieve); nstore ($my_complex_data,
> 'filename');
> my $revived = retrieve('filename');
>
> But have the intermediate file format be JSON instead of Storable's
> format.
>
> We also have to go through a process to get executable modules installed,
>  so if it can be pure perl, I can just copy the file to a local
> directory, check it into the project, and use it without delay. I can get
> executables installed, but they have to be approved through a process, and
> then someone has to make sure they're installed on every machine
> everywhere, including all teh machines on LSF. so executables are
> possible, but likely a bit more painful.
>
> I looked for JSON on CPAN and found... hundreds of matches???
>
>
> It looks like JSON::PP is pure perl and does what I want.
> https://metacpan.org/pod/JSON::PP
> however, it says: "JSON::PP is a pure perl JSON decoder/encoder, and
> (almost) compatible to
> much faster JSON::XS"
>
> How compatible is "almost" compatible?
>
>
> I'm not actually worried about being compatible with JSON::XS. I'm
> worried about being compatible with whatever JSON file some python script
> ends up generating, or generating a JSON file that a python script may
> have to read.
>
>
> JSON::XS https://metacpan.org/pod/JSON::XS says:
> "This module converts Perl data structures to JSON and vice versa. Its
> primary goal is to be correct"
>
> How "incorrect" might JSON::PP be?
>
>
> JSON::PP says it is not "java script friendly" and that "If you need
> JavaScript-friendly RFC7159-compliant pure perl module, try JSON::Tiny,"
>
>
> https://metacpan.org/pod/JSON::Tiny
>
>
> JSON::Tiny says "it is among the fastest pure-Perl implementations of RFC
>  7159." But it doesn't say anything about "correct"ness.
>
>
> So, what's the point of JSON::PP if JSON::Tiny does everything better and
>  is also pure perl?
>
> Has anyone used any of these modules?
>
>
> If I wanted to take a complex perl data structure, save it to JSON
> format, and then have a python script read that JSON file, possibly modify
> the structure, and save it back as JSON, and then my perl script open that
>  JSON back up, and read it back in again, which module is most likely to
> be cross-language compatible?
>
> Any help woudl be appreciated.
> Greg
>
>
> _______________________________________________
> Boston-pm mailing list
> [email protected]
> https://mail.pm.org/mailman/listinfo/boston-pm
>
>


--