Closed sugitach closed 6 years ago
JSON::XS is the same, too.
@sugitach
If you have installed JSON::XS, then JSON usually uses it instead of JSON::PP. If you think this is a JSON::PP issue as you've said in the issue title, use it explicitly for clarity. ( perl -MJSON::PP ....
)
And you must have been using an old version of JSON::PP (like 2.27xxx) if you see the same result. Upgrade it to the latest version (2.97001) if you can. You'll see a different result.
If you stick to JSON::XS (and older versions of JSON::PP), then this issue is your problem, not ours: read the JSON::XS documentation. It clearly explains how to specify the type. ( https://metacpan.org/pod/JSON::XS#PERL-%3E-JSON ) Because you've done explicit stringification in your code, it's natural (at least to the JSON::XS author) that JSON(::XS) returns a stringified value. This might be hard to understand at first, but it certainly is a consistent way when you need to handle more subtle values.
You migth want to use JSON::Types ( https://metacpan.org/pod/JSON::Types ) or JSON::Typist ( https://metacpan.org/pod/JSON::Typist ) to mitigate this issue.
You might also want to use Cpanel::JSON::XS, or JSON::Tiny/Mojo::JSON, all of which don't have this issue (though they might have their own issues; that's another story).
@charsbar Thank you for your reply.
The following three points were confirmed.
Then I selected Cpanel::JSON::XS. Thanks again.
The following code will fail.
->
Data::Dumper is not fail.
Even if it is not "eq", if you execute the string operation in general, the output changes without assigning it.