.\" This manpage is Copyright (C) 2016 MongoDB, Inc. .\" .\" Permission is granted to copy, distribute and/or modify this document .\" under the terms of the GNU Free Documentation License, Version 1.3 .\" or any later version published by the Free Software Foundation; .\" with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. .\" A copy of the license is included in the section entitled "GNU .\" Free Documentation License". .\" .TH "BSON_AS_JSON" "3" "2016\(hy10\(hy12" "libbson" .SH NAME bson_as_json() \- The bson_as_json() function shall encode bson as a JSON encoded UTF-8 string. .SH "SYNOPSIS" .nf .nf char * bson_as_json (const bson_t *bson, size_t *length); .fi .fi .SH "PARAMETERS" .TP .B bson A .B bson_t . .LP .TP .B length An optional location for the length of the resulting string. .LP .SH "DESCRIPTION" The .B bson_as_json(3) function shall encode .B bson as a JSON encoded UTF\(hy8 string. The caller is responsible for freeing the resulting UTF\(hy8 encoded string by calling .B bson_free(3) with the result. If non\(hyNULL, .B length will be set to the length of the result in bytes. .SH "RETURNS" If successful, a newly allocated UTF\(hy8 encoded string and .B length is set. Upon failure, NULL is returned. .SH "EXAMPLE" .nf char *str = bson_as_json (doc, NULL); printf ("%s\en", str); bson_free (str); .fi .B .SH COLOPHON This page is part of libbson. Please report any bugs at https://jira.mongodb.org/browse/CDRIVER.