circular-json-es6
circular JSON.stringify and JSON.parse, for environments with native ES6 Map
Last updated 8 years ago by yyx990803 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install circular-json-es6 
SYNC missed versions from official npm registry.

circular-json-es6

A replacement for JSON.stringify and JSON.parse that can handle circular references (persists reference structure).

This implementation requires environments with native ES6 Map support, but is decently faster than circular-json (see benchmark with npm run bench).

var CircularJSON = require('circular-json-es6')

var obj = {}
obj.a = obj

var clone = CircularJSON.parse(CircularJSON.stringify(obj))

clone.a === clone // -> true

NOTE

The default stringify method optimizes for cases where no circular reference is present by trying a plain JSON.stringify first. This means if no circular references are found in the data then it will not persist multiple (but non-circular) references to the same object.

If you want to enforce reference persistence, use CircularJSON.stringifyStrict instead.

Current Tags

  • 2.0.2                                ...           latest (8 years ago)

5 Versions

  • 2.0.2                                ...           8 years ago
  • 2.0.1                                ...           9 years ago
  • 2.0.0                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |