js-string

0.1.0 • Public • Published

js-string

Stringify JSON without double quotes ""

Install

yarn add js-string

Usage

const jsString = require('js-string')
jsString(obj)
// or
jsString(json)

Example

Input:

{
  foo: 'bar',
  bar: {
    foo: 'bar',
    baz: 'lol'
  },
  baz: [1, 2, 3],
  zoo: [
    {
      foo: 'bar',
      wow: new Date()
    },
    {
      baz: [1,2, 'foo'],
      haha: undefined,
      lol: {
        foo: {
          bar: 123
        }
      }
    }
  ]
}

Output, using JSON.stringify():

{
  "foo": "bar",
  "bar": {
    "foo": "bar",
    "baz": "lol"
  },
  "baz": [
    1,
    2,
    3
  ],
  "zoo": [
    {
      "foo": "bar",
      "wow": "2016-12-30T09:49:57.255Z"
    },
    {
      "baz": [
        1,
        2,
        "foo"
      ],
      "lol": {
        "foo": {
          "bar": 123
        }
      }
    }
  ]
}

Output, using js-string:

{
  foo: 'bar',
  bar: {
    foo: 'bar',
    baz: 'lol'
  },
  baz: [1, 2, 3],
  zoo: [{
    foo: 'bar',
    wow: 'Fri Dec 30 2016 17:49:57 GMT+0800 (CST)'
  }, {
    baz: [1, 2, 'foo'],
    haha: undefined,
    lol: {
      foo: {
        bar: 123
      }
    }
  }]
}

License

MIT © EGOIST

Readme

Keywords

none

Package Sidebar

Install

npm i js-string

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • rem