Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 12.1   12.2   12.3   12.4   12.5   13.0   13.1   13.2   13.3   13.4    Statistic    FMM    Blog  

MongoDB.JSONtoBSON

Converts JSON to BSON.

Component Version macOS Windows Linux Server iOS SDK
MongoDB 12.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "MongoDB.JSONtoBSON"; JSON { ; FileName } )   More

Parameters

Parameter Description Example Flags
JSON The JSON to convert.
FileName The file name to use. Optional

Result

Returns FILE Container or error.

Description

Converts JSON to BSON.
Returns a container value with FILE entry containing BSON.
You can use EncodeHex() to convert it to hex string if needed.

Examples

Encode a blank object:

HexEncode ( MBS( "MongoDB.JSONtoBSON"; "{}"))

Example result: 0500000000

Encode an array with string:

HexEncode ( MBS( "MongoDB.JSONtoBSON"; "[\"hello\"]"))

See also

This function checks for a license.

Created 22nd May 2022, last changed 29th January 2023


MongoDB.IsTracing - MongoDB.Keys

💬 Ask a question or report a problem