Nodejs QueryString Query string

Source: Internet
Author: User

The QueryString module provides some useful functions for parsing and Formatting URL query strings: Using the following methods:

Const QueryString = require (' querystring ')//import node built-in module

Querystring.escape (str)

STR <string>

URL encoding for a given STR

This method is provided to QueryString () and is usually not used directly. The reason why it is open is to rewrite the implementation of the encoding when needed by assigning a function to the querystring.escape.

Querystring.parse (Str,[,sep[,eq[,option]])

All optional parameters are used to split the Str.

Such as:

Console.log (Qs.parse (' name:zhangsan,age:10 ', ', ', ': '))

The second parameter, meaning to, not split by, divides the string into intervals, dividing the result into two sets of data (the default is &)

Divide the word and string into {name: ' Zhangsan ', age:10} according to the comma

Third parameter: Meaning to Split field names and field values in each set of data

With name: ' Zhangsan ' as column, Name field name Zhangsan field value

Querystring.stringify usage is the opposite of odd.

Nodejs QueryString Query string

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.