karenetheridge / JSON-Schema-Modern

Validate data against a schema using a JSON Schema
https://metacpan.org/release/JSON-Schema-Modern/
Other
10 stars 1 forks source link

Passes allow_bignum to JSON::MaybeXS which JSON::XS doesn't support #79

Closed puck closed 7 months ago

puck commented 11 months ago

Hey,

I'm getting:

{
   "errors": [
      {
         "error": "EXCEPTION: Can't locate object method \"allow_bignum\" via package \"JSON::XS\" at /usr/share/perl5/JSON/MaybeXS.pm line 50.\n",
         "instanceLocation": "",
         "keywordLocation": ""
      }
   ],
   "valid": false
}

If I look in JSON::XS there is no method called allow_bignum. If I remove allow_bignum from /usr/share/perl5/JSON/Schema/Modern.pm then I can load my schema (okay, let's by honest, I can get to the next error).

This on Debian Unstable versions are:

Which all appear to be the latest versions available via CPAN.

Cheers, Andrew

karenetheridge commented 11 months ago

The problem here is you are using JSON::XS, which is not interface-compatible with JSON::PP and Cpanel::JSON::XS. I believe there were plans to drop all use of JSON::XS via JSON::MaybeXS, but that hasn't happened yet. Nevertheless, I would highly recommend you switch: https://metacpan.org/pod/Perl::Critic::Policy::Community::DiscouragedModules#JSON::XS

Glad to see you're using JSON::Schema::Modern! I haven't heard of many people using it yet (or maybe they're just silently content?) :)

puck commented 11 months ago

Oh, interesting. Would it be possible to also have JSON::MaybeXS know it can't use JSON::XS if incompatible parameters are passed in? The error message was a bit "huh?!" (I can raise a bug report against JSON::MaybeXS as well, but you'll see it there as well!)

They might be silently content, but I'm about to ping you on IRC about some behaviour that was me confused. :)

karenetheridge commented 7 months ago

This was fixed in version 0.578 by removing the possibility of JSON::XS being used as a json backend.