object2string

1.0.2 • Public • Published

Object To String

Stringify objects as Strings(Custom Splicing).

Installation

npm i --save object2string

Usage

const object2string = require('object2string')

Example

const query = object2string({
    name: 'yumcc',
    age: 24,
    gender: 1,
    height: 170,
    weight: 65,
    blog: 'https://www.yumcc.com'
})

returns

name=yumcc&age=24&gender=1&height=170&weight=65&blog=https://www.yumcc.com

Options

const query = object2string({
    name: 'yumcc',
    age: 24,
    gender: 1,
    height: 170,
    weight: 65,
    blog: 'https://www.yumcc.com'
}, {
    sort: true, // default: false
    splicing: '|', // default: &
    relative: ':', // default: =
    encode: [ 'blog' ] // default: []
})

returns

age:24|blog:https%3A%2F%2Fwww.yumcc.com|gender:1|height:170|name:yumcc|weight:65

Package Sidebar

Install

npm i object2string

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

2.51 kB

Total Files

4

Last publish

Collaborators

  • yumcc