Why is include_root_in_json true now

I’ve been trying to understand this for a bit now, and I can’t find
any discussion on why the change was made. The default value used to
be false, but now it is true?

When I do something like this it is nice to have the root value:
format.json { render :json => @user }

But if I want to output extra variables too it gets annoying to have
the root node twice

format.json { render :json => { :success => true, :user => @user } }

{“success”:true, “user:”{“user”:{}}}}

In the second case it seems weird because I have to double parse the
‘user’ key…I assume there is a reason this decision was made so I’d
like to understand that.

Also, if I do decide to just set include_root_in_json to false, what
is the best place to do that.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs