| Module | Sequel::Plugins::JsonSerializer::DatasetMethods |
| In: |
lib/sequel/plugins/json_serializer.rb
|
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.
# File lib/sequel/plugins/json_serializer.rb, line 199
199: def to_json(*a)
200: if opts = a.first.is_a?(Hash)
201: opts = model.json_serializer_opts.merge(a.first)
202: a = []
203: else
204: opts = model.json_serializer_opts
205: end
206: res = row_proc ? all.map{|obj| Literal.new(obj.to_json(opts))} : all
207: opts[:root] ? {model.send(:pluralize, model.send(:underscore, model.to_s)) => res}.to_json(*a) : res.to_json(*a)
208: end