Public Instance methods
to_json
(*a)
Return a JSON string representing an array of all objects in this dataset. Takes the same options as the the instance method, and passes them to every instance.
[show source]
# File lib/sequel/plugins/json_serializer.rb, line 204 def to_json(*a) if opts = a.first.is_a?(Hash) opts = model.json_serializer_opts.merge(a.first) a = [] else opts = model.json_serializer_opts end res = if row_proc array = if opts[:array] opts = opts.dup opts.delete(:array) else all end array.map{|obj| Literal.new(obj.to_json(opts))} else all end opts[:root] ? {model.send(:pluralize, model.send(:underscore, model.to_s)) => res}.to_json(*a) : res.to_json(*a) end