JSPM

  • Created
  • Published
  • Downloads 2551485
  • Score
    100M100P100Q204370F
  • License MIT

Stringify your JSON at max speed

Package Exports

  • fast-json-stringify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fast-json-stringify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fast-json-stringify

fast-json-stringify is x5 faster than JSON.stringify().

Benchmarks:

JSON.stringify x 1,681,132 ops/sec ±0.59% (88 runs sampled)
fast-json-stringify x 5,117,658 ops/sec ±1.44% (87 runs sampled)

Example

const fastJson = require('fast-json-stringify')
const stringify = fastJson({
  title: 'Example Schema',
  type: 'object',
  properties: {
    firstName: {
      type: 'string'
    },
    lastName: {
      type: 'string'
    },
    age: {
      description: 'Age in years',
      type: 'integer'
    }
  }
})

console.log(stringify({
  firstName: 'Matteo',
  lastName: 'Collina',
  age: 32
}))

API

fastJsonStringify(schema)

Build a stringify() function based on jsonschema.

Supported types:

  • `integer'
  • `number'
  • `array'
  • `object'
  • `null'

And nested ones, too. Date instances are serialized with toISOString().

License

MIT