Module: BSON::JSON

Overview

Provides common behaviour for JSON serialization of objects.

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#to_json(*args) ⇒ String

Note:

All types must implement as_json.

Converting an object to JSON simply gets it’s hash representation via as_json, then converts it to a string.

Examples:

Convert the object to JSON

object.to_json

Returns:

  • (String)

    The object as JSON.

Since:

  • 2.0.0



35
36
37
# File 'lib/bson/json.rb', line 35

def to_json(*args)
  as_json.to_json(*args)
end