import { parse } from "https://deno.land/x/pure_json@1.0.0-beta.1/mod.ts";
Safe converts a JavaScript Object Notation (JSON) string into an object.
It does not throw errors compared to JSON.parse
.
Parameters
A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.
import { parse } from "https://deno.land/x/pure_json@$VERSION/mod.ts";
import { assertEquals } from "https://deno.land/std@$VERSION/testing/asserts.ts";
const [data, err] = parse(`{ "hello": "world"}`);
assertEquals(err, undefined);
assertEquals(data, { hello: "world" });