Giter Site home page Giter Site logo

circular-json-es6's Introduction

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.

circular-json-es6's People

Contributors

coolzjy avatar evidens avatar yyx990803 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

circular-json-es6's Issues

not working

TypeError: Converting circular structure to JSON\n    at JSON.stringify (<anonymous>)\n    at Object.exports.stringifyStrict (/root/server-scripts/node_modules/circular-json-es6/index.js:93:18)\n    at Object.stringify (/root/server-scripts/node_modules/circular-json-es6/index.js:72:20)\n    at send (/root/server-scripts/lib/mail/index.js:35:33)\n    at Object.send (/root/server-scripts/lib/mail/index.js:72:13)\n    at Queue.<anonymous> (/root/server-scripts/lib/bull/index.js:18:18)\n    at emitOne (events.js:115:13)\n    at Queue.emit (events.js:210:7)\n    at /root/server-scripts/node_modules/bull/lib/queue.js:786:15\n    at tryCatcher (/root/server-scripts/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/root/server-scripts/node_modules/bluebird/js/release/promise.js:512:31)\n    at Promise._settlePromise (/root/server-scripts/node_modules/bluebird/js/release/promise.js:569:18)\n    at Promise._settlePromise0 (/root/server-scripts/node_modules/bluebird/js/release/promise.js:614:10)\n    at Promise._settlePromises (/root/server-scripts/node_modules/bluebird/js/release/promise.js:693:18)\n    at Async._drainQueue (/root/server-scripts/node_modules/bluebird/js/release/async.js:133:16)\n    at Async._drainQueues (/root/server-scripts/node_modules/bluebird/js/release/async.js:143:10
```

hi

Hello, I am a novice. It took me a few days to understand the design implementation of this code. I would like to ask if the design here USES some algorithm.It's so cleverly designed that it's amazing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.