Skip to main content
Module

x/denodb/deps.ts>Bson.EJSON.parse

MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Go to Latest
function Bson.EJSON.parse
import { Bson } from "https://deno.land/x/denodb@v1.0.40/deps.ts";
const { parse } = Bson.EJSON;

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

Examples

Example 1

const { EJSON } = require('/error/unknown:bson?from=bson');
const text = '{ "int32": { "$numberInt": "10" } }';

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

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

Parameters

text: string
optional
options: EJSON.Options