json
.intrude import mongodb
var obj = new JsonObject
obj["age"] = 10
obj["name"] = "Rick"
obj["ELS"] = new JsonArray
var bson = new BSON.from_json(obj)
assert bson.to_s == """{ "age" : 10, "name" : "Rick", "ELS" : [ ] }"""
# Returns a new BSON object initialized from the content of `json`.
#
# ~~~
# intrude import mongodb
# var obj = new JsonObject
# obj["age"] = 10
# obj["name"] = "Rick"
# obj["ELS"] = new JsonArray
# var bson = new BSON.from_json(obj)
# assert bson.to_s == """{ "age" : 10, "name" : "Rick", "ELS" : [ ] }"""
# ~~~
init from_json(json: JsonObject) do
init(new NativeBSON.from_json_string(json.to_json.to_cstring))
end
lib/mongodb/mongodb.nit:69,2--82,4