SYNOPSIS

#include <bson.h>

char *
bson_as_json (const bson_t *bson,
              size_t       *length);

DESCRIPTION

The bson_as_json() function shall encode bson as a JSON encoded UTF-8 string.

The caller is responsible for freeing the resulting UTF-8 encoded string by calling bson_free() with the result.

If non-NULL, length will be set to the length of the result in bytes.

RETURN VALUE

A newly allocated UTF-8 encoded JSON string which should be freed with bson_free().

ERRORS

NULL is returned if there was a failure to encode the document. This can happen if bson is corrupt or malicious in content.

SEE ALSO

AUTHORS

This page was written by MongoDB, Inc.