JSPM

jsonloop

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q16477F
  • License MIT

JSON.{parse, stringify} compatible for circular JSON

Package Exports

  • jsonloop

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 (jsonloop) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

jsonloop

JSON.{parse, stringify} compatible for circular JSON

https://www.npmjs.com/package/jsonloop

https://serapath.github.io/jsonloop/

use

npm install jsonloop

const jsonloop = require('jsonloop')
const defaultSeperator = '.'
const cJSON = jsonloop(defaultSeperator)

var obj2 = { foo: { bar: [{ x: 'y'}, { y: 'x' }], xx: { yy: 'zz' } }, a: 'b' }
obj2.foo.bar.push(obj2.foo.xx)

const json = cJSON.stringify(obj2, 0, 2)
console.log(json) /* {
  "foo": {
    "bar": [
      {
        "x": "y"
      },
      {
        "y": "x"
      },
      {
        "yy": "zz"
      }
    ],
    "xx": "#.foo.bar.2"
  },
  "a": "b"
} */
const obj2 = cJSON.parse(json)
console.log(obj2) /*{
  "foo": {
    "bar": [
      {
        "x": "y"
      },
      {
        "y": "x"
      },
      {
        "yy": "zz"
      }
    ],
    "xx": { yy: "zz" }
  },
  "a": "b"
} */