Oj.dump ignores :symbol_keys option #54

Closed
trevorrowe opened this Issue Dec 11, 2012 · 3 comments

Projects

None yet

2 participants

@trevorrowe

When dumping a hash, the :symbol_keys option does not seem to have any effect when passed as false, example:

require 'oj'

# notice the ':' prefix of they key
puts Oj.dump({:abc => 123}, :symbol_keys => false)
#=> {":abc":123}

# same result
puts Oj.dump({:abc => 123}, :symbol_keys => true)
#=> {":abc":123}

Is this expected behavior?

@ohler55
Owner

That is expected behavior. The symbolize_keys option only applies to loading.

@trevorrowe

What is your recommendation if I have a hash with symbol keys, that I want dumped to JSON without the colon prefixes? I can recursively stringify-keys on the hash, but that does not seem like it would be very performant. Thoughts?

@ohler55
Owner
@ohler55 ohler55 closed this Dec 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment