https://github.com/puntorigen/jsdump
Like JSON stringify but unquoting JS values and objects
https://github.com/puntorigen/jsdump
Last synced: 3 months ago
JSON representation
Like JSON stringify but unquoting JS values and objects
- Host: GitHub
- URL: https://github.com/puntorigen/jsdump
- Owner: puntorigen
- License: mit
- Created: 2023-01-07T14:16:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-07T18:01:22.000Z (over 2 years ago)
- Last Synced: 2025-03-10T23:54:38.049Z (3 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsdump
Like JSON stringify but unquoting JS values and objects.
Give it any object and it will create a string representation for it, without quoting the keys and quoting just the string values, resembling the look of that object as used within the source code when writing it to a source file or evaluating it as code.Example:
```js
const test = {
name: 'Lola',
age: '23',
type: 'parrot'
isAnimal: `()=>{
if (this.type=='parrot') return true;
return false;
}`
}
const jsDump = require('jsdump');
const stringAsJS = jsDump(test);
/*
stringAsJS contents will look like:
{
name: 'Lola',
age: 23,
type: 'parrot'
isAnimal: ()=>{
if (this.type=='parrot') return true;
return false;
}
}
*/
```