Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/hex/src/data/deps.ts>mongo.Bson.EJSON.parse

An ecosystem delivering practices, philosophy and portability.
Go to Latest
function mongo.Bson.EJSON.parse
import { mongo } from "https://deno.land/x/hex@0.5.15/src/data/deps.ts";
const { parse } = mongo.Bson.EJSON;

Parse an Extended JSON string, constructing the JavaScript value or object described by that string.

Examples

Example 1

const { EJSON } = require('bson');
const text = '{ "int32": { "$numberInt": "10" } }';

// prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } }
console.log(parse(text, { relaxed: false }));

// prints { int32: 10 }
console.log(parse(text));

Parameters

text: string
optional
options: Options