bson_init_from_json (3) - Linux Manuals
bson_init_from_json: The bson_init_from_json() function will initialize a new bson_t by parsing the JSON found in data. Only a single JSON object may exist in data or an error will be set and false returned.
Command to display bson_init_from_json
manual in Linux: $ man 3 bson_init_from_json
NAME
bson_init_from_json() - The bson_init_from_json() function will initialize a new bson_t by parsing the JSON found in data. Only a single JSON object may exist in data or an error will be set and false returned.
SYNOPSIS
bool
bson_init_from_json (bson_t *bson,
const char *data,
ssize_t len,
bson_error_t *error);
PARAMETERS
- bson
-
A
bson_t
\&.
- data
-
A UTF-8 encoded string containing valid JSON.
- len
-
The length of
data
in bytes excluding a trailing
\0
or -1 to determine the length with
strlen(3)
\&.
- error
-
An optional location for a
bson_error_t
\&.
DESCRIPTION
The
bson_init_from_json(3)
function will initialize a new
bson_t
by parsing the JSON found in
data
\&. Only a single JSON object may exist in
data
or an error will be set and false returned.
data
should be in
MongoDB Extended JSON
format.
ERRORS
Errors are propagated via the
error
parameter.
RETURNS
true if successful, otherwise false and
error
is set.
COLOPHON
This page is part of libbson.
Please report any bugs at
https://jira.mongodb.org/browse/CDRIVER.
Pages related to bson_init_from_json
- bson_init_static (3) - The bson_init_static() function shall shall initialize a read-only bson_t on the stack using the data provided. No copies of the data will be made and therefore must remain valid for the lifetime of the bson_t.
- bson_init (3) - The bson_init() function shall initialize a bson_t that is placed on the stack. This is equivalent to initializing a bson_t to BSON_INITIALIZER.
- bson_iter_array (3) - The bson_iter_array() function shall retrieve the raw buffer of a sub-array from iter. iter MUST be on an element that is of type BSON_TYPE_ARRAY. This can be verified with bson_iter_type() or the BSON_ITER_HOLDS_ARRAY() macro.
- bson_iter_as_bool (3) - Fetches the current field as if it were a boolean.
- bson_iter_as_int64 (3) - The bson_iter_as_int64() function shall return the contents of the current element as if it were a BSON_TYPE_INT64 element. The currently supported casts include:
- bson_iter_binary (3) - This function shall return the binary data of a BSON_TYPE_BINARY element. It is a programming error to call this function on a field that is not of type BSON_TYPE_BINARY. You can check this with the BSON_ITER_HOLDS_BINARY() macro or bson_iter_type().
- bson_iter_bool (3) - The bson_iter_bool()function shall return the boolean value of a BSON_TYPE_BOOL element. It is a programming error to call this function on an element other than BSON_TYPE_BOOL. You can check this with bson_iter_type() or BSON_ITER_HOLDS_BOOL().
- bson_iter_code (3) - This function returns the contents of a BSON_TYPE_CODE field. The length of the string is stored in length if non-NULL.
- bson_iter_codewscope (3) - The bson_iter_codewscope() function acts similar to bson_iter_code() except for BSON_TYPE_CODEWSCOPE elements. It also will provide a pointer to the buffer for scope, which can be loaded into a bson_t using bson_init_static().
- bson_iter_date_time (3) - The bson_iter_date_time() function shall return the number of miliseconds since the UNIX epoch, as contained in the BSON_TYPE_DATE_TIME element.