stringify-object-lite
v0.1.7
Published
An extremely light-weight function to recursively stringifying objects without adding slashes and other types of url-encoding. clocks in at only 628 bytes minified
Downloads
4
Readme
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",
},
},
}