Module: BSON::JSON

Included in:
Binary, Code, CodeWithScope, Decimal128, MaxKey, MinKey, ObjectId, Regexp, Regexp::Raw, Timestamp
Defined in:
lib/bson/json.rb

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

Since:

  • 2.0.0


33
34
35
# File 'lib/bson/json.rb', line 33

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