Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

prevent quoted null when to_json is called on nil relationship #41

Open
wants to merge 1 commit into
base: release-1.2
Choose a base branch
from
Open

Conversation

soopa
Copy link

@soopa soopa commented Sep 25, 2013

This is an update to #23 from 2011 to target the release-1.2 branch rather than master given the divergence of those two branches, and abandonment of master. The impact and code change is the same as before…


Fixes the case where calling something like:

resource.to_json(:relationships => { :nested_resource => { :only => [:id] } })

When the nested resource returns nil, would return invalid JSON like…

{
  "id":1,
  "nested_resouce":"null"
}

Rather than valid JSON like…

{
  "id":1,
  "nested_resouce":null
}

(Note the quotes around null)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant