![]() |
TerraForge3D
2.3.1
3D Terrain And Landscape Generator
|
|
inlinestatic |
Serializes the given JSON object j
to BSON and returns a vector containing the corresponding BSON-representation.
BSON (Binary JSON) is a binary format in which zero or more ordered key/value pairs are stored as a single entity (a so-called document).
The library uses the following mapping from JSON values types to BSON types:
JSON value type | value/range | BSON type | marker |
---|---|---|---|
null | null | null | 0x0A |
boolean | true , false | boolean | 0x08 |
number_integer | -9223372036854775808..-2147483649 | int64 | 0x12 |
number_integer | -2147483648..2147483647 | int32 | 0x10 |
number_integer | 2147483648..9223372036854775807 | int64 | 0x12 |
number_unsigned | 0..2147483647 | int32 | 0x10 |
number_unsigned | 2147483648..9223372036854775807 | int64 | 0x12 |
number_unsigned | 9223372036854775808..18446744073709551615 | – | – |
number_float | any value | double | 0x01 |
string | any value | string | 0x02 |
array | any value | document | 0x04 |
object | any value | document | 0x03 |
binary | any value | binary | 0x05 |
out_of_range.407 | if j.is_number_unsigned() && j.get<std::uint64_t>() > 9223372036854775807 |
out_of_range.409 | if a key in j contains a NULL (U+0000) |
type_error.317 | if !j.is_object() |
j
is required to be an object: j.is_object() == true
.[in] | j | JSON value to serialize |
@complexity Linear in the size of the JSON value j.
@liveexample{The example shows the serialization of a JSON value to a byte vector in BSON format.,to_bson}
Definition at line 25317 of file json.hpp.