0.1.7 • Published 7 years ago

stringify-object-lite v0.1.7

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

stringify-object-lite

An extremely light-weight function to recursively stringify objects without adding slashes and other types of url-encoding. Clocks in at only 628 bytes minified with no dependencies.

Installation

npm install --save stringify-object-lite;
or
yarn add stringify-object-lite

Usage

For ES6 and up
import stringifyObjectLite from 'stringify-object-lite';
For ES5
var stringifyObjectLite = require("stringify-object-lite");

To stringify the following object:

var obj = {
  a: "A string",
  b: "Another string",
  c: ["an", "array", "of", "strings", "and", 1, "int"],
  nested: {
    a1: "nested",
    b2: "object of strings",
    c3: {
      andA: "deeply",
      nested: "object"
    }
  }
}

Simply pass your object to the provided function:

stringifyObjectLite(obj)

It will output the following as a single-line string (I've beautified this example for better legibility):

{
    a: "A string",
    b: "Another string",
    c: ["an", "array", "of", "strings", "and", "1", "int"],
    nested: {
        a1: "nested",
        b2: "object of strings",
        c3: {
            andA: "deeply",
            nested: "object",
        },
    },
}
0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago