Skip to main content
Module

x/simple_utility/mod.ts>jsonLoad

Useful snippet collection.
Go to Latest
function jsonLoad
import { jsonLoad } from "https://deno.land/x/simple_utility@v1.5.1/mod.ts";

Read JSON file and convert to object. If JSON file does not exist create new file with default value. Argument default value also act as type definition.

Examples

Example 1

import dresource from "./resource.json" assert {type: "json"};
const resource = await jsonLoad("./resource.json", dresource);

Parameters

path: string
def: T

Returns

Promise<T>