Methods

Files

Kernel

Private Instance Methods

JSON(object, *args) click to toggle source

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 374
374:   def JSON(object, *args)
375:     if object.respond_to? :to_str
376:       JSON.parse(object.to_str, args.first)
377:     else
378:       JSON.generate(object, args.first)
379:     end
380:   end
j(*objs) click to toggle source

Outputs objs to STDOUT as JSON strings in the shortest form, that is in one line.

     # File lib/json/common.rb, line 352
352:   def j(*objs)
353:     objs.each do |obj|
354:       puts JSON::generate(obj, :allow_nan => true, :max_nesting => false)
355:     end
356:     nil
357:   end
jj(*objs) click to toggle source

Ouputs objs to STDOUT as JSON strings in a pretty format, with indentation and over many lines.

     # File lib/json/common.rb, line 361
361:   def jj(*objs)
362:     objs.each do |obj|
363:       puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
364:     end
365:     nil
366:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.