Nodejs-querystring Module

Source: Internet
Author: User

    • JavaScript standard Reference Tutorial (Alpha)
    • Draft II: node. js
    • QueryString Module
    • GitHub
    • TOP
QueryString Module

From the JavaScript standard reference tutorial (Alpha), by Ruan Feng

Directory
    • Querystring.parse ()

querystringModules are primarily used to parse query strings.

Querystring.parse ()

querystring.parse()method is used to parse a query string into a JavaScript object.

var str = ‘foo=bar&abc=xyz&abc=123‘;querystring.parse(str)// { foo: ‘bar‘, abc: [ ‘xyz‘, ‘123‘ ] }

parseMethod can accept four parameters altogether.

  querystring. Parse (str[, sep[, eq[, options     
    • str: Query string to parse
    • sep: The delimiter between multiple key-value pairs, which defaults to&
    • eq: The delimiter between the key name and the key value, which defaults to=
    • options: Configuration object, which has two properties, decodeURIComponent is a function used to restore the encoded string, by default querystring.unescape() , the property specifies the maximum number of maxKeys properties to resolve, by default 1000 , if set to 0 represents the maximum quantity of an unrestricted attribute.

The previous example omits the next three parameters, and the complete invocation form is as follows.

querystring.parse(  ‘w=%D6%D0%CE%C4&foo=bar‘, null, null, { decodeURIComponent: gbkDecodeURIComponent })

parseMethod can also be used to parse a generic string.

var str = ‘name:Sophie;shape:fox;condition:new‘;querystring.parse(str, ‘;‘, ‘:‘)// {// name: ‘Sophie‘,// shape: ‘fox‘,// condition: ‘new‘,// }
Message comments Powered byDisqus

Copyright Notice | Last modified on 2015-06-06

Nodejs-querystring Module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.