---
name: "bson_new_from_data"
section: "3"
platform: "linux"
package: "libbson-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/bson_new_from_data"
---

# bson\_new\_from\_data(3)

## SYNOPSIS

```
bson_t *
bson_new_from_data (const uint8_t *data, size_t length);
```

## PARAMETERS

- •

  **data**: A BSON encoded document buffer.

- •

  **length**: The length of **data** in bytes.

## DESCRIPTION

The *bson\_new\_from\_data()* function shall create a new *bson\_t* on the heap and copy the contents of **data**. This may be helpful when working with language bindings but is generally expected to be slower.

## RETURNS

A newly allocated *bson\_t* if successful, otherwise NULL.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
