diff --git a/config.ts b/config.ts index 89dbfa9..1085189 100644 --- a/config.ts +++ b/config.ts @@ -1,7 +1,12 @@ +import { JsonValue, parse } from "std/jsonc/mod.ts"; + export class Config { _data; - constructor(data: { [x: string]: unknown }) { - this._data = Object.assign({}, data); + constructor(data: JsonValue) { + this._data = <{ [x: string]: unknown }> Object.assign( + {}, + data, + ); } _return_string(key: string) { const v = this._data[key]; @@ -58,5 +63,5 @@ export class Config { export async function load_settings(path: string) { const s = (new TextDecoder()).decode(await Deno.readFile(path)); - return new Config(JSON.parse(s)); + return new Config(parse(s)); } diff --git a/deno.lock b/deno.lock index bc06504..fb052e1 100644 --- a/deno.lock +++ b/deno.lock @@ -6,6 +6,9 @@ "https://deno.land/std@0.188.0/flags/mod.ts": "17f444ddbee43c5487568de0c6a076c7729cfe90d96d2ffcd2b8f8adadafb6e8", "https://deno.land/std@0.188.0/fmt/colors.ts": "d67e3cd9f472535241a8e410d33423980bec45047e343577554d3356e1f0ef4e", "https://deno.land/std@0.188.0/fs/exists.ts": "29c26bca8584a22876be7cb8844f1b6c8fc35e9af514576b78f5c6884d7ed02d", + "https://deno.land/std@0.188.0/json/common.ts": "ecd5e87d45b5f0df33238ed8b1746e1444da7f5c86ae53d0f0b04280f41a25bb", + "https://deno.land/std@0.188.0/jsonc/mod.ts": "b88dce28eb3645667caa856538ae2fe87af51410822544a0b45a4177ef3bd7dd", + "https://deno.land/std@0.188.0/jsonc/parse.ts": "2910e33bc7c3b243e3b6f3a39ce4d6ca84337b277a8df6f2ad2d9e4adbcddc08", "https://deno.land/std@0.188.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", "https://deno.land/std@0.188.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b", "https://deno.land/std@0.188.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0",