ohler55/oj_mimic_json

Oj.add_to_json()

stereobooster opened this issue · 6 comments

I suppose we need to add Oj.add_to_json().

Agreed. Thanks.

Let me take that back, maybe. The add_to_json call is used to mimic the require 'json/add/rational' call and similar. Oj.mimc_JSON is usually only needed to make it easier with Rails to just require the gem and have the json gem mimicing behavior. Add the Oj.add_to_json() call makes sense if the normal use case for Rails is to have the json/add required called. If not then it probably should not be included. Do you know what the normal use case is?

@ohler55 Is any of this still useful with the new OJ version 3 release? It had a focus of improving specifically the json library and Rails compatibility.

I don't think add Oj.add_to_json is appropriate for the oj_mimic_json as it mimics the require 'json/add/xxx' calls which is not the same as just requiring the json gem. I suggest that this issue should be closed.

Now it makes sense to me, when you put it like that

Oj.add_to_json(x) is equivalent of require 'json/add/x'

Exactly. Thanks for closing.