Giter Site home page Giter Site logo

url-qs's Introduction

url-qs

A tool which transfer url between object and string.

# Every value should be string when parse string to object

# plain
test('parse to plain object', t => {
    t.deepEqual(fn.parse('a=1&b=2'), {a: '1', b: '2'})
})

test('stringify object with array', t => {
    t.deepEqual(fn.stringify({a: 1, b: [2, 3]}), "a=1&b%5B%5D=2&b%5B%5D=3")
})

test('stringify object with array 2', t => {
    t.deepEqual(fn.stringify({a: 1, b: [2, 3]}), "a=1&b%5B%5D=2&b%5B%5D=3")
})

# complicate object
test('stringify complicate object', t => {
    t.deepEqual(fn.stringify({
        a: 1, 
        b: [2, 3], 
        c: {d: 4, e: [5, 6]},
        f: {g: 7, h: 8}
    }), "a=1&b%5B%5D=2&b%5B%5D=3&c%5Bd%5D=4&c%5Be%5D%5B%5D=5&c%5Be%5D%5B%5D=6&f%5Bg%5D=7&f%5Bh%5D=8")
})

Install && Usage

npm install url-qs --save
import qs from 'url-qs'

const str = qs.stringify(paramObject)
const obj = qs.parse(str)

url-qs's People

Contributors

shatle avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.