Xbasic

json_to_bson Function

Syntax

json_to_bson(c json)

Arguments

jsonCharacter

A string containing the JSON to convert to BSON.

Description

BSON was created by the developers of Mongo DB. BSON is JSON data that is converted to binary.

Example

js = <<%str%
{
    "OrderId":10248,
    "ProductID":11,
    "UnitPrice":14,
    "Quantity":12,
    "Discount":0
}
%str%

dim xml as c 
? json_to_bson(js)
= 0000 : 4c 00 00 00 10 4f 72 64 65 72 49 64 00 08 28 00 
0010 : 00 10 50 72 6f 64 75 63 74 49 44 00 0b 00 00 00 
0020 : 10 55 6e 69 74 50 72 69 63 65 00 0e 00 00 00 10 
0030 : 51 75 61 6e 74 69 74 79 00 0c 00 00 00 10 44 69 
0040 : 73 63 6f 75 6e 74 00 00 00 00 00 00

See Also