What is the difference between these Perl JSON modules?

What is the difference between Perl JSON modules below?

I came across JSON :: PP and JSON :: XS . The JSON :: PP documentation says it is compatible with JSON :: XS . What does it mean?

I'm not sure what the difference is between the two, let alone which one to use. Can someone clarify?

+4
source share
2 answers

Perl modules sometimes have different implementations. The suffix is ::PPdesigned to implement Pure Perl (i.e., for portability), the suffix is ::XSdesigned to be implemented on the basis of C (i.e., for speed), and JSONthis is only the top-level module itself (i.e. the one you are on actually use).

As @Quentin noted, this site has a good description. Quote:

Json

JSON.pm is a wrapper around JSON::PPand JSON::XS- it also contains a bunch of moderately crazy things for compatibility reasons, including extra padding code for very old perls [...]

JSON :: PP

This is the standard pure perl implementation, and if you are not performance dependent, there is nothing wrong with using it [...]

JSON :: XS

A ridiculously fast JSON implementation in C. Absolutely wonderful [...]

, JSON . , , .. .

Perl JSON RHEL, , : ( ) CPAN, .

( GNU/Linux), cpan . , .

, , ( GNU/Linux):

$ perl -e 'use JSON;'

, . , .

+11

JSON, cpan JSON

use JSON;

my $result = from_json($json);
if($result->{field})
{
  # YOUR CODE
};
-2

Source: https://habr.com/ru/post/1650262/


All Articles