If object is string-like, parse the string and return the parsed result as a Ruby data structure. Otherwise, generate a JSON text from the Ruby data structure object and return it.
The opts argument is passed through to generate/parse respectively. See generate and parse for their documentation.
# File lib/json/common.rb, line 462 462: def JSON(object, *args) 463: if object.respond_to? :to_str 464: JSON.parse(object.to_str, args.first) 465: else 466: JSON.generate(object, args.first) 467: end 468: end
Outputs objs to STDOUT as JSON strings in the shortest form, that is in one line.
# File lib/json/common.rb, line 440 440: def j(*objs) 441: objs.each do |obj| 442: puts JSON::generate(obj, :allow_nan => true, :max_nesting => false) 443: end 444: nil 445: end
Ouputs objs to STDOUT as JSON strings in a pretty format, with indentation and over many lines.
# File lib/json/common.rb, line 449 449: def jj(*objs) 450: objs.each do |obj| 451: puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false) 452: end 453: nil 454: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.