String, object, and JSON handler functions in node. js

Source: Internet
Author: User

querystring. Parse ()

Turning a string into an object is the parameter string that is taken on the URL to the array object.

QueryString. Parse (str, [Sep], [EQ], [options])

Receive parameters:

STR to convert the string

Sep set delimiter, default to ' & '

EQ setting Assignment, default = ' = '

[Options] Maxkeys The maximum length of an acceptable string, default is 1000

Querystring.parse (' Foo=bar&baz=qux&baz=quux&corge ')//  returns' Bar ', Baz: [' Qux ', ' Quux '], Corge: '}

Querystring.stringify ()

The object is formatted as a parameter string, and obj is the object to be formatted, the required parameter.

Querystring.stringify (Obj,[sep],[eq])
var a = {a:1,b:2}; Json.stringify (a); // Result: "{" A ": 1," B ": 2}"

Json.parse () and Json.stringify ()

Parse is used to parse a JSON object from a string, such as

var str = ' {' name ': ' Huangxiaojian ', ' age ': ' + '} '// Result:'"" Huangxiaojian " __proto__: Object

Stringify () is used to parse out a string from an object, such as

var a = {a:1,b:2}// Result:json.stringify (a)"{" A ": 1," B ": 2}"

String, object, and JSON handler functions in node. js

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.