1.1.7 • Published 2 years ago

json-helper-toolkit v1.1.7

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

json-helper-toolkit

Toolkit for easier JSON manipulation.

Code Examples

/test.json

{
  "name": "test-name"
}

/src/index.ts

import { modifyJson, readJson } from "json-helper-toolkit";

// ------

interface Test {
    name: string;
    changed?: boolean;
}

// Argument path should be based on the current work directory.
// You can check the directory with "process.cwd()".
const [, data] = readJson<Test>("test.json");

console.log(data.name); // "test-name"

data.name = "changed-name";
data.changed = true;
modifyJson("test.json", data);

// ------

const [modifiedPath, modifiedData] = readJson<Test>("test.json");
console.log(`Checking "${modifiedPath}"`);

if (modifiedData) {
    // Console : changed-name
    console.log(modifiedData.name);

    // Console : true
    console.log(modifiedData.changed);
}
1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.1

2 years ago

1.0.2

2 years ago

1.1.0

2 years ago

1.0.6

2 years ago

1.1.4

2 years ago

1.0.5

2 years ago

1.1.3

2 years ago

1.0.4

2 years ago

1.1.2

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago