oj: Oj.mimic_JSON don't work

Hi,

Looks like I am doing something wrong, but I can’t understand it.

In my rails code, I have initializers who calls Oj.mimic_JSON and a byebug in active support to_json alias. In my rails console I do the next:

> [1,2,3].to_json
.. byebug opens up in active support json encoder ..
> Oj.mimic_JSON
> [1,2,3].to_json
.. byebug opens up in active support json encoder ..

What am I doing wrong?

  • Rails 4.2.8
  • Ruby 2.3.3
  • Oj 2.18.1

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 37 (20 by maintainers)

Most upvoted comments

Ok, a few unit tests and then a release later tonight.

@ohler55 use mimic_JSON with optimize_rails ? If I do this I get this as response - "#\u003cActiveModel::ArraySerializer:0x007fb0bb303630\u003e"

And If I use only mimic_JSON the to_json still goes to active support -

> MyModel.last.method(:to_json)
=> #<Method: MyModel(Object)#to_json(to_json_with_active_support_encoder)>