Skip to content

Instantly share code, notes, and snippets.

@laserlemon
Created May 26, 2011 20:40
Show Gist options
  • Save laserlemon/994024 to your computer and use it in GitHub Desktop.
Save laserlemon/994024 to your computer and use it in GitHub Desktop.
YAJL encoding initializer
[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
@laserlemon
Copy link
Author

Note: This skips checks for circular references.

@laserlemon
Copy link
Author

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