{"name":"json-cycle","version":"1.0.4","description":"Encode/decode circular structures for converting to and from JSON.","keywords":["json","cycle","stringify","parse","circular","recursive","circular","reference","recursion"],"main":"cycle.js","private":false,"repository":{"type":"git","url":"git+ssh://git@github.com/valery-barysok/json-cycle.git"},"bugs":{"url":"https://github.com/valery-barysok/json-cycle.git/issues"},"homepage":"https://github.com/valery-barysok/json-cycle.git","files":["LICENSE","README.md","cycle.js"],"author":{"name":"Valery Barysok","email":"valery.barysok@gmail.com"},"contributors":[{"name":"Douglas Crockford","email":"douglas@crockford.com","url":"douglascrockford"}],"scripts":{"test":"mocha --reporter spec --bail --check-leaks test/","test-ci":"istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/","test-cov":"istanbul cover ./node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/","test-tap":"mocha --reporter tap --check-leaks test/"},"license":"MIT","engines":{"node":">= 0.8.0"},"devDependencies":{"chai":"3.2.0","coveralls":"2.11.4","istanbul":"^0.3.19","mocha":"2.3.2"},"gitHead":"5314359118d87128a16af44c86bcd787bed0e655","_id":"json-cycle@1.0.4","_shasum":"22def39fd1cfe46a1a3db78f9b18e3c8eb86fc9c","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"valery-barysok","email":"valery.barysok@gmail.com"},"dist":{"shasum":"22def39fd1cfe46a1a3db78f9b18e3c8eb86fc9c","tarball":"http://registry-npm.ywwl.com/json-cycle/download/json-cycle-1.0.4.tgz","integrity":"sha512-5sygjlNYHcbnNySfwZuA+Yd+PPleDSGoXSe5m0lNfvU2oSQin8FffJL5mDkVk5zMGoxLAQh5neW/2gLUHHg8Yg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCds0AFLPIcWI7AjpfGQcNbr7qzTrVXpGBvEdYKdXeXOwIhAPu1vdy7KKAQwCmPNZsaCP550OYblaM8nOus+n+b4MIa"}],"size":4288,"noattachment":false,"key":"/json-cycle/-/json-cycle-1.0.4.tgz"},"maintainers":[{"name":"valery-barysok","email":"valery.barysok@gmail.com"}],"directories":{},"readme":"# json-cycle\n\n[![NPM Version][npm-version-image]][npm-url]\n[![NPM Downloads][npm-downloads-image]][npm-url]\n[![Node.js Version][node-image]][node-url]\n[![Build Status][travis-image]][travis-url]\n[![Coverage Status][coveralls-image]][coveralls-url]\n\nUtilities provide ability to encode/decode circular structures for converting to and from JSON.\n\nBased on [JSON-js][jsonjs-url]\n\n## Install\n\nIn your project:\n\n```\nnpm install json-cycle --save\n```\n\n## Details\n\nThis package contains four functions, decycle, retrocycle, stringify and parse,\nwhich make it possible to encode cyclical structures and convert them to JSON, and\nthen recover them. This is a capability that is not provided by ES5. JSONPath \nis used to represent the links. [http://GOESSNER.net/articles/JsonPath/]\n\n> Note: If you stringify javascript structure and then parse it back in some cases you can get not the same javascript structure. For instance, if it contains Date object you get String form of it.\n\n## Methods\n\n- [decycle](#decycle)\n- [retrocycle](#retrocycle)\n- [stringify](#stringify)\n- [parse](#parse)\n\n### decycle(object)\n\n> Note: `decycle` function makes a deep copy of any provided structure while original `decycle` function from [JSON-js][jsonjs-url] does not make copy for `Boolean`, `Date`, `Number`, `RegExp` and `String` objects.\n\nMakes a deep copy of an provided structure with resolving all circular references.\nThe duplicate references which part of an cycle are replaced with an object of the form\n\n    {$ref: PATH}\n\nwhere the PATH is a JSONPath string that locates the first occurrence.\n\nExample:\n\n```js\n    jc = require('json-cycle');\n    var a = {};\n    a.self = a;\n    console.log(JSON.stringify(jc.decycle(a)));\n```\n\nOutput:\n\n```js\n    {{\"$ref\":\"$\"}}\n```\n\n### retrocycle(object)\n\nreturns provided object\n\nRestores an object that was reduced by `decycle` function. Members whose values are\nobjects of the form\n\n    {$ref: PATH}\n\nare replaced with references to the value found by the PATH. This will\nrestore cycles. **The object will be mutated**.\n\n> Note: The eval function is used to locate the values described by a PATH. The\nroot object is kept in a $ variable. A regular expression is used to\nassure that the PATH is extremely well formed. The regexp contains nested\n* quantifiers. That has been known to have extremely bad performance\nproblems on some browsers for very long strings. A PATH is expected to be\nreasonably short. A PATH is allowed to belong to a very restricted subset of\nGoessner's JSONPath.\n\nExample:\n\n```js\n    jc = require('json-cycle');\n    var s = '{{\"$ref\":\"$\"}}';\n    jc.retrocycle(JSON.parse(s));\n```\n\nOutput:\n\n```js\n    produced object equals to \n    var a = {};\n    a.self = a;\n```\n\n### stringify(object)\n\nIt equals to `JSON.stringify(decycle(object))`\n\n### parse(object)\n\nIt equals to `retrocycle(JSON.parse(object))`\n\n## License\nMIT &copy; 2015-... Valery Barysok, Douglas Crockford\n\n[npm-version-image]: https://img.shields.io/npm/v/json-cycle.svg?style=flat-square\n[npm-downloads-image]: https://img.shields.io/npm/dm/json-cycle.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/json-cycle\n[travis-image]: https://img.shields.io/travis/valery-barysok/json-cycle/master.svg?style=flat-square\n[travis-url]: https://travis-ci.org/valery-barysok/json-cycle\n[coveralls-image]: https://img.shields.io/coveralls/valery-barysok/json-cycle/master.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/valery-barysok/json-cycle?branch=master\n[node-image]: https://img.shields.io/node/v/json-cycle.svg?style=flat-square\n[node-url]: http://nodejs.org/download/\n[jsonjs-url]: https://github.com/douglascrockford/JSON-js\n","publish_time":1442682977600,"_cnpm_publish_time":1442682977600,"dist-tags":{"latest":"1.5.0"}}