ruby / json

JSON implementation for Ruby
https://ruby.github.io/json
Other
704 stars 333 forks source link

Issue with calling `JSON::Pure::Parser` in new releases #701

Closed david22swan closed 2 weeks ago

david22swan commented 2 weeks ago

Following earlier issues with using json-pure alongside json we removed the json-pure gem from our dependencies as it was judged that it was no longer needed. As part of this we left a line in place JSON::Pure::Parser as the output that it givs is superior for our purposes.

require 'json/pure'
JSON.parser = JSON::Pure::Parser

Prior to the newest release of the json gem this worked without issues, however as of 2.8.0 this has begun causing errors and I wanted to confirm whether this was a bug, or expected.

Failure/Error: require 'json/pure'

LoadError:
  cannot load such file -- json/pure
byroot commented 2 weeks ago

JSON::Pure no longer exist as of 2.8.0.

As part of this we left a line in place JSON::Pure::Parser as the output that it givs is superior for our purposes.

Could you detail what you mean here? As long as pure existed we tried to have it as consistent as possible with Ext. How was the output different?

david22swan commented 2 weeks ago

TBH I am not entirely sure, I was not part of the team when that decision was made and my knowledge of it comes fro a large warning comment in the code.

If it has been removed though, will work around this and see what I can do. Thanks for replying fast.

byroot commented 2 weeks ago

If for some reason JSON.parse cause you issues, I'm interested in knowing what's wrong.

And if you have to work around it, it's probably not hard to vendor the old Pure::Parser implementation in your code base.

david22swan commented 2 weeks ago

The original code was about 7 years ago, so likely that the differences have disappeared since.

david22swan commented 2 weeks ago

Hey, just getting back to this because you seemed interested, but the main change was in how the data was passed back, when checking for errors the JSON:Pure::Parser gave us this:

\Aexpected ':' in object

while the JSON::Ext::Parser gives us this:

unexpected token at '{\\\"test\\\"\\\": \\\"value\\\"}'
byroot commented 2 weeks ago

Ah I see. That was for the different error messages. To be fair, the Ext::Parser error messages could certainly be improve.

Thanks for the info.