Skip to content

yumcc-com/object2string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Object to String!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published