SlideShare a Scribd company logo
1 of 11
Query String Parameters &
Methods in NodeJS
What is Query String in NodeJS
• There are ways to deal with query strings thanks to the Node.js Query
String. It can transform a query string into a JSON object and the
other way around.
• Now, there are methods for parsing and formatting URL query strings
available in the Node.js query string module. The following command
will access the query string module:
• const querystring = require(‘querystring’);
In NodeJS the following are the six Query
String Parameters listed below.
• decode()
• encode()
• escape(str)
• parse(str[, sep[, eq[, options]]])
• stringify(obj[, sep[, eq[, options]]])
• unescape(str)
Query String methods in NodeJS with
Description
querystring.parse() Method in NodeJS
• The URL query string is parsed into an object with a key-value pair
using the querystring.parse() function.
• We cannot utilize Object methods like obj.toString or
obj.hasOwnProperty since the object we receive is not a JavaScript
object ().
• The syntax for the method is below.
• querystring.parse( str[, sep[, eq[, options]]]) )
• The syntax for the method is below.
• querystring.parse( str[, sep[, eq[, options]]]) )
• As seen from the above syntax this method accepts four parameters, which
are described below.
• str: This is the only required string field and it specifies in the query string that
has to be parsed.
• sep: If provided, it is an optional string parameter that specifies the substring that
will be used to separate the query string’s key and value pairs. The default value
used is “&”.
• eq: It is an optional string field that is used in the query string to separate the keys
from the values. The default value used is “=”.
• options: It is an optional object field that is used to modify the behavior of the
method. It can have the following parameters:
• decodeURIComponent: It is a function that would be used to provide the query string’s
encoding format. The default setting is querystring.unescape(), about which we will learn
later.
• maxKeys: This value indicates how many keys in total should be processed. Any number of
keys can be parsed if the value is set to “0,” which eliminates any counting restrictions. The
default setting is “1000.”
• The syntax for the method is below.
• querystring. stringify( obj[, sep[, eq[, options]]]) )
• The method accepts four parameters, which are specified below, as can be seen
from the syntax above.
• obj: The sole object field that is necessary defines the object that has to be
serialized.
• sep: It is a string field that is optional and, if provided, provides the substring that
will be used to separate the key and value pairs in the query string. “&” is the
default value, which is typically used.
• eq: The substring used to separate the query string’s keys and values are specified
in this optional string parameter. In most cases, the default value is “=”.
• options: It is an optional object field that is used to change how the method
behaves. It can have the following parameters:
• decodeURIComponent: It is a function that would be utilized to specify the query string’s
encoding format. The default value is querystring.escape(), about which we will learn later.
querystring.decode() Method in NodeJS
• A simple alias for the querystring.parse() function is querystring.decode().
We can use it in our parsing example. Add the following code to the
querystring.js file we previously established.
• // Import the querystring module
• const querystring = require(“querystring”);
• // Specify this URL query string to be parsed
• let urlQueryString =
“name=nabendu&units=kgs&units=pounds&login=false”;
• // Use the parse() method on the string
• let parsedObj = querystring.decode(urlQueryString);
• console.log(“Parsed Query 1:”, parsedObj);
• Run the node querystring.js command from a terminal, as you did before.
The result will be identical to that of the querystring.parse() function.
• Parsed Query 1: [Object: null prototype] { name: ‘bhanu’, units: [ ‘kgs’,
‘pounds’ ], login: ‘false’ }
querystring.stringify() Method in NodeJS
• A supplied object that has a key-value pair can be utilized to create a
query string using the querystring.stringify() method. When compared
to querystring.parse(), it is the exact opposite.
• The string, integer, and Boolean values for the key can all be
converted using it. An array of strings, numbers, or Boolean values
can also be used as values. Serialization is the process of converting an
object to a query string.
• Unless we indicate an alternative encoding format, the most recent
UTF-8 encoding format is taken into account. But since UTF-8
encoding is the industry standard and includes all international
characters,
querystring.encode() Method in NodeJS
• A simple alias for the querystring.stringify() technique is querystring.encode(). We can use it in our
stringify example. Add the following code to the querystring.js file we previously established.
• // Import the querystring module
• const querystring = require(“querystring”);
• // Name the object that required serialisation.
• let obj = {
• name: “nabendu”,
• access: true,
• role: [“developer”, “architect”, “manager”],
• };
• // Use the stringify() method on the object
• let queryString = querystring.encode(obj);
• console.log(“Query String 1:”, queryString);
• Run the terminal command node querystring.js like we did earlier. And the results will match those
of the querystring.stringify() function.
• Query String 1: name=nabendu&access=true&role=developer&role=architect&role=manager
• querystring.escape(str) Method in NodeJS
• The querystring.escape() function is typically only utilised by the
querystring.stringify() method.
• f.querystring.unescape(str) Method
• The querystring.unescape() method is often only utilised by the
querystring.parse() method..

More Related Content

Similar to Query String Parameters & Methods in NodeJS.pptx

json.ppt download for free for college project
json.ppt download for free for college projectjson.ppt download for free for college project
json.ppt download for free for college project
AmitSharma397241
 
4java Basic Syntax
4java Basic Syntax4java Basic Syntax
4java Basic Syntax
Adil Jafri
 
String and string manipulation x
String and string manipulation xString and string manipulation x
String and string manipulation x
Shahjahan Samoon
 

Similar to Query String Parameters & Methods in NodeJS.pptx (20)

json.ppt download for free for college project
json.ppt download for free for college projectjson.ppt download for free for college project
json.ppt download for free for college project
 
Single page application 05
Single page application   05Single page application   05
Single page application 05
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
5variables in c#
5variables in c#5variables in c#
5variables in c#
 
Java
Java Java
Java
 
Spark schema for free with David Szakallas
Spark schema for free with David SzakallasSpark schema for free with David Szakallas
Spark schema for free with David Szakallas
 
Data structure Unit-I Part A
Data structure Unit-I Part AData structure Unit-I Part A
Data structure Unit-I Part A
 
String.pptx
String.pptxString.pptx
String.pptx
 
CH1 ARRAY (1).pptx
CH1 ARRAY (1).pptxCH1 ARRAY (1).pptx
CH1 ARRAY (1).pptx
 
Lecture 3.pptx
Lecture 3.pptxLecture 3.pptx
Lecture 3.pptx
 
4java Basic Syntax
4java Basic Syntax4java Basic Syntax
4java Basic Syntax
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptx
 
c++ UNIT II.pptx
c++ UNIT II.pptxc++ UNIT II.pptx
c++ UNIT II.pptx
 
Aspdot
AspdotAspdot
Aspdot
 
Preparing Java 7 Certifications
Preparing Java 7 CertificationsPreparing Java 7 Certifications
Preparing Java 7 Certifications
 
Java R20 - UNIT-5.pdf
Java R20 - UNIT-5.pdfJava R20 - UNIT-5.pdf
Java R20 - UNIT-5.pdf
 
Java R20 - UNIT-5.docx
Java R20 - UNIT-5.docxJava R20 - UNIT-5.docx
Java R20 - UNIT-5.docx
 
Json the-x-in-ajax1588
Json the-x-in-ajax1588Json the-x-in-ajax1588
Json the-x-in-ajax1588
 
String and string manipulation x
String and string manipulation xString and string manipulation x
String and string manipulation x
 
Lecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksLecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinks
 

More from HemaSenthil5

DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptxDBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
HemaSenthil5
 
Buffer Management in DBMS systemsss.pptx
Buffer Management in DBMS systemsss.pptxBuffer Management in DBMS systemsss.pptx
Buffer Management in DBMS systemsss.pptx
HemaSenthil5
 
Usability evaluation for Business Intelligence applications.pptx
Usability  evaluation  for  Business  Intelligence  applications.pptxUsability  evaluation  for  Business  Intelligence  applications.pptx
Usability evaluation for Business Intelligence applications.pptx
HemaSenthil5
 
godds-servicescontinuum-151010201328-lva1-app6891 (1).pptx
godds-servicescontinuum-151010201328-lva1-app6891 (1).pptxgodds-servicescontinuum-151010201328-lva1-app6891 (1).pptx
godds-servicescontinuum-151010201328-lva1-app6891 (1).pptx
HemaSenthil5
 
business intelligence of its important Teams.pptx
business intelligence of its important Teams.pptxbusiness intelligence of its important Teams.pptx
business intelligence of its important Teams.pptx
HemaSenthil5
 
Big Data Mining Methods in Medical Applications [Autosaved].pptx
Big Data Mining Methods in Medical Applications [Autosaved].pptxBig Data Mining Methods in Medical Applications [Autosaved].pptx
Big Data Mining Methods in Medical Applications [Autosaved].pptx
HemaSenthil5
 
module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...
HemaSenthil5
 

More from HemaSenthil5 (16)

DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptxDBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
DBMS-Recovery techniques dfggrjfchdfhwrshfxbvdgtytdfx.pptx
 
Buffer Management in DBMS systemsss.pptx
Buffer Management in DBMS systemsss.pptxBuffer Management in DBMS systemsss.pptx
Buffer Management in DBMS systemsss.pptx
 
Usability evaluation for Business Intelligence applications.pptx
Usability  evaluation  for  Business  Intelligence  applications.pptxUsability  evaluation  for  Business  Intelligence  applications.pptx
Usability evaluation for Business Intelligence applications.pptx
 
godds-servicescontinuum-151010201328-lva1-app6891 (1).pptx
godds-servicescontinuum-151010201328-lva1-app6891 (1).pptxgodds-servicescontinuum-151010201328-lva1-app6891 (1).pptx
godds-servicescontinuum-151010201328-lva1-app6891 (1).pptx
 
Enterprize and departmental BusinessIintelligence.pptx
Enterprize and departmental BusinessIintelligence.pptxEnterprize and departmental BusinessIintelligence.pptx
Enterprize and departmental BusinessIintelligence.pptx
 
MODULE 3 -Normalization bwdhwbifnweipfnewknfqekndd_1.ppt
MODULE 3 -Normalization bwdhwbifnweipfnewknfqekndd_1.pptMODULE 3 -Normalization bwdhwbifnweipfnewknfqekndd_1.ppt
MODULE 3 -Normalization bwdhwbifnweipfnewknfqekndd_1.ppt
 
BI STRATEGY and tactical analytics .pptx
BI STRATEGY and tactical analytics .pptxBI STRATEGY and tactical analytics .pptx
BI STRATEGY and tactical analytics .pptx
 
MODULE 3 -Normalization_1.ppt moduled in design
MODULE 3 -Normalization_1.ppt moduled in designMODULE 3 -Normalization_1.ppt moduled in design
MODULE 3 -Normalization_1.ppt moduled in design
 
IT6010-BUSINESS-INTELLIGENCE-Question-Bank_watermark.pdf
IT6010-BUSINESS-INTELLIGENCE-Question-Bank_watermark.pdfIT6010-BUSINESS-INTELLIGENCE-Question-Bank_watermark.pdf
IT6010-BUSINESS-INTELLIGENCE-Question-Bank_watermark.pdf
 
business intelligence of its important Teams.pptx
business intelligence of its important Teams.pptxbusiness intelligence of its important Teams.pptx
business intelligence of its important Teams.pptx
 
Big Data Mining Methods in Medical Applications [Autosaved].pptx
Big Data Mining Methods in Medical Applications [Autosaved].pptxBig Data Mining Methods in Medical Applications [Autosaved].pptx
Big Data Mining Methods in Medical Applications [Autosaved].pptx
 
Internet-of-Things-for-Sm.9272728.powerpoint.pptx
Internet-of-Things-for-Sm.9272728.powerpoint.pptxInternet-of-Things-for-Sm.9272728.powerpoint.pptx
Internet-of-Things-for-Sm.9272728.powerpoint.pptx
 
Business Models.pptx Download millions of presentations
Business Models.pptx Download millions of presentationsBusiness Models.pptx Download millions of presentations
Business Models.pptx Download millions of presentations
 
Node js installation steps.pptx slide share ppts
Node js installation steps.pptx slide share pptsNode js installation steps.pptx slide share ppts
Node js installation steps.pptx slide share ppts
 
module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...
 
iot health applications.pptx
iot health applications.pptxiot health applications.pptx
iot health applications.pptx
 

Recently uploaded

Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 

Recently uploaded (20)

Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 

Query String Parameters & Methods in NodeJS.pptx

  • 1. Query String Parameters & Methods in NodeJS
  • 2. What is Query String in NodeJS • There are ways to deal with query strings thanks to the Node.js Query String. It can transform a query string into a JSON object and the other way around. • Now, there are methods for parsing and formatting URL query strings available in the Node.js query string module. The following command will access the query string module: • const querystring = require(‘querystring’);
  • 3.
  • 4. In NodeJS the following are the six Query String Parameters listed below. • decode() • encode() • escape(str) • parse(str[, sep[, eq[, options]]]) • stringify(obj[, sep[, eq[, options]]]) • unescape(str)
  • 5. Query String methods in NodeJS with Description querystring.parse() Method in NodeJS • The URL query string is parsed into an object with a key-value pair using the querystring.parse() function. • We cannot utilize Object methods like obj.toString or obj.hasOwnProperty since the object we receive is not a JavaScript object (). • The syntax for the method is below. • querystring.parse( str[, sep[, eq[, options]]]) )
  • 6. • The syntax for the method is below. • querystring.parse( str[, sep[, eq[, options]]]) ) • As seen from the above syntax this method accepts four parameters, which are described below. • str: This is the only required string field and it specifies in the query string that has to be parsed. • sep: If provided, it is an optional string parameter that specifies the substring that will be used to separate the query string’s key and value pairs. The default value used is “&”. • eq: It is an optional string field that is used in the query string to separate the keys from the values. The default value used is “=”. • options: It is an optional object field that is used to modify the behavior of the method. It can have the following parameters: • decodeURIComponent: It is a function that would be used to provide the query string’s encoding format. The default setting is querystring.unescape(), about which we will learn later. • maxKeys: This value indicates how many keys in total should be processed. Any number of keys can be parsed if the value is set to “0,” which eliminates any counting restrictions. The default setting is “1000.”
  • 7. • The syntax for the method is below. • querystring. stringify( obj[, sep[, eq[, options]]]) ) • The method accepts four parameters, which are specified below, as can be seen from the syntax above. • obj: The sole object field that is necessary defines the object that has to be serialized. • sep: It is a string field that is optional and, if provided, provides the substring that will be used to separate the key and value pairs in the query string. “&” is the default value, which is typically used. • eq: The substring used to separate the query string’s keys and values are specified in this optional string parameter. In most cases, the default value is “=”. • options: It is an optional object field that is used to change how the method behaves. It can have the following parameters: • decodeURIComponent: It is a function that would be utilized to specify the query string’s encoding format. The default value is querystring.escape(), about which we will learn later.
  • 8. querystring.decode() Method in NodeJS • A simple alias for the querystring.parse() function is querystring.decode(). We can use it in our parsing example. Add the following code to the querystring.js file we previously established. • // Import the querystring module • const querystring = require(“querystring”); • // Specify this URL query string to be parsed • let urlQueryString = “name=nabendu&units=kgs&units=pounds&login=false”; • // Use the parse() method on the string • let parsedObj = querystring.decode(urlQueryString); • console.log(“Parsed Query 1:”, parsedObj); • Run the node querystring.js command from a terminal, as you did before. The result will be identical to that of the querystring.parse() function. • Parsed Query 1: [Object: null prototype] { name: ‘bhanu’, units: [ ‘kgs’, ‘pounds’ ], login: ‘false’ }
  • 9. querystring.stringify() Method in NodeJS • A supplied object that has a key-value pair can be utilized to create a query string using the querystring.stringify() method. When compared to querystring.parse(), it is the exact opposite. • The string, integer, and Boolean values for the key can all be converted using it. An array of strings, numbers, or Boolean values can also be used as values. Serialization is the process of converting an object to a query string. • Unless we indicate an alternative encoding format, the most recent UTF-8 encoding format is taken into account. But since UTF-8 encoding is the industry standard and includes all international characters,
  • 10. querystring.encode() Method in NodeJS • A simple alias for the querystring.stringify() technique is querystring.encode(). We can use it in our stringify example. Add the following code to the querystring.js file we previously established. • // Import the querystring module • const querystring = require(“querystring”); • // Name the object that required serialisation. • let obj = { • name: “nabendu”, • access: true, • role: [“developer”, “architect”, “manager”], • }; • // Use the stringify() method on the object • let queryString = querystring.encode(obj); • console.log(“Query String 1:”, queryString); • Run the terminal command node querystring.js like we did earlier. And the results will match those of the querystring.stringify() function. • Query String 1: name=nabendu&access=true&role=developer&role=architect&role=manager
  • 11. • querystring.escape(str) Method in NodeJS • The querystring.escape() function is typically only utilised by the querystring.stringify() method. • f.querystring.unescape(str) Method • The querystring.unescape() method is often only utilised by the querystring.parse() method..