like-json
Stringify at perfect performance. +1200%
Benchmark it yourself: https://jsperf.com/likejson
Install
Node.js:
npm i like-json
Browser:
Features
Methods
like: Functionlike: String
Examples
json
const like = ; let stringify = like; let string1 = JSON;let string2 = ; console; // true
stringify
const like = ; let string1 = JSON;let string2 = like; console; // true
How it works?
There is no processing, so same than a simple concatenation:
console;// -> { return '{"msg":"' + omsg + '"}';}
Because that there is a conflict with double quotes:
msg: 'account "user" created' // object"msg":"account \"user\" created" // JSON.stringify"msg":"account "user" created" // like.stringify
You can use single quotes, in that way avoid escape which reduces performance.
If really want to use double quotes then can use options:
let options = encode: true ;let string1 = JSON;let string2 = like;console; // true
Tests
npm test
Inside of stringify.test.js can see more info.
License
Code released under the MIT License.