We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
undefined
\n
const perfectJson = require('perfect-json'); const data = { name: 'Dmitriy', surname: 'Pushkov', asdf: undefined, skills: ['Java\nScript', 'Node.js', 'ES6'], env: { node: '14.0.0', eslint: true, babel: true, typescript: false } }; console.log(perfectJson(data, { singleLine: ({ key }) => { return ['skills', 'env'].includes(key); } }));
Actual (improper json):
{ "name": "Dmitriy", "surname": "Pushkov", "asdf": undefined, "skills": ["Java Script", "Node.js", "ES6"], "env": { "node": "14.0.0", "eslint": true, "babel": true, "typescript": false } }
Expected:
{ "name": "Dmitriy", "surname": "Pushkov", "skills": ["Java\nScript", "Node.js", "ES6"], "env": { "node": "14.0.0", "eslint": true, "babel": true, "typescript": false } }
The text was updated successfully, but these errors were encountered:
fix for newline and undefined: https://gist.github.com/theBowja/5d8f0fc80da350945a4703527745dcf8/revisions
Sorry, something went wrong.
also need to take into account Date and BigInt
if (item instanceof Date) { return JSON.stringify(item); } if (typeof item === 'bigint') { return JSON.stringify(item); }
No branches or pull requests
undefined
values should be removed from the output.\n
newline characters aren't handled properly.Actual (improper json):
Expected:
The text was updated successfully, but these errors were encountered: