json-destringify
Parses JSON while eagerly destringifying. A stringification tree is returned to allow the parsed/cleaned result to be edited and converted back to the original stringified format
Installation:
$ yarn add json-destringify
$ npm install json-destringify
Build:
$ yarn build
$ yarn deploy
$ npm run build
$ npm run deploy
Test:
$ yarn test
$ npm run test
Usage:
import { destringify, restringify } from 'json-destringify';
const sampleInput = JSON.stringify({ property: 'true' });
const { result, tree } = destringify(sampleInput);
const sampleOutput = restringify({ result, tree });
const changedResult = {
property: false
};
const changedOutput = restringify({ result: changedResult, tree });
Example:
import { destringify, restringify } from 'json-destringify';
const input = {
property: [
JSON.stringify({
key: JSON.stringify(123)
})
]
};
const destringified = destringify(input);
const restringified = restringify(destringified);
const { result, tree } = destringified;