Created
May 26, 2011 20:40
-
-
Save laserlemon/994024 to your computer and use it in GitHub Desktop.
YAJL encoding initializer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[NilClass, TrueClass, FalseClass].each do |klass| | |
klass.class_eval do | |
def as_json(options = nil) | |
self | |
end | |
end | |
end | |
ActiveSupport::JSON::Encoding::Encoder.class_eval do | |
def encode(value, use_options = true) | |
jsonified = use_options ? value.as_json(options) : value.as_json | |
Yajl.dump(jsonified) | |
end | |
end |
Note: This skips checks for circular references.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: This skips checks for circular references.