Reviews by makamaka

cpanratings
 

RSS

JSON (2.51)

Because I saw Ben Bullock's terrible review, I comment a bit.

The how-to of (de|en)code_json, (from|to)_json and object methods
are described in the document (each sections and SYNOPSIS).
decode_json expects an UTF-8 (binary) string and identical to:

JSON->new->utf8->decode( $utf8_encoded_text )

So when you correctly use Encode::encode, the below code works.

# $string is a string (or UNICODE)

decode_json( encode('utf8', $string ) );

If decode_json croaks, it's your wrong use of Encode method.
That is not because of the JSON interface difficulty.

Additionally,
from_json is identical to:

JSON->new->decode( $scalar );

# from_json( $scalar, { allow_nonref => 1 } );

# => JSON->new->allow_nonref->decode( $scalar );

So from_json() can take a non utf8 encoded string.

Please see to
Encode, perluniintro,
search.cpan.org/~mlehmann/JSON-XS-2.3...
search.cpan.org/~makamaka/JSON-2.51/l...

makamaka - 2011-05-21T22:04:40 (permalink)

5 out of 8 found this review helpful. Was this review helpful to you?  Yes No

JSON-PP (2.27103)

Hi, Taro Nishino.
Yes, I was perhaps the first to transplant json to Perl as you said.
I appreciate your hearty review!

makamaka - 2011-01-13T07:25:18 (permalink)

2 out of 2 found this review helpful. Was this review helpful to you?  Yes No