Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/VienDinhCom/jsonfile
📚 Easily read/write JSON files in Deno
https://github.com/VienDinhCom/jsonfile
deno json jsonfile read-json read-json-sync write-json write-json-sync
Last synced: 30 days ago
JSON representation
📚 Easily read/write JSON files in Deno
- Host: GitHub
- URL: https://github.com/VienDinhCom/jsonfile
- Owner: VienDinhCom
- License: mit
- Created: 2020-10-04T15:51:05.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-06T23:30:33.000Z (over 3 years ago)
- Last Synced: 2024-11-02T07:05:11.186Z (about 1 month ago)
- Topics: deno, json, jsonfile, read-json, read-json-sync, write-json, write-json-sync
- Language: TypeScript
- Homepage: https://deno.land/x/jsonfile
- Size: 18.6 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - Maxvien/jsonfile - 📚 Easily read/write JSON files in Deno (deno)
README
# jsonfile
Easily read/write JSON files in Deno
## readJson
Reads a JSON file and then parses it into an object
```ts
import { readJson, readJsonSync } from "https://deno.land/x/jsonfile/mod.ts";const f = await readJson("./foo.json");
const foo = readJsonSync("./foo.json");
```## writeJson
Writes an object to a JSON file.
### WriteJsonOptions
- replacer : An array of strings and numbers that acts as a approved list for
selecting the object properties that will be stringified.
- space : Adds indentation, white space, and line break characters to the
return-value JSON text to make it easier to read.You can also specify options from `Deno.WriteFileOptions` to configure how the
file is written.```ts
import { writeJson, writeJsonSync } from "https://deno.land/x/jsonfile/mod.ts";writeJson("./target.json", { foo: "bar" }, { spaces: 2 }); // returns a promise
writeJsonSync("./target.json", { foo: "bar" }, { replacer: ["foo"] }); // void// appends to the file instead of rewriting
writeJsonSync("./target.json", { foo: "bar" }, { append: true });
```