Node.js Tutorial
- Node.js Tutorial
- Install Node.js on Windows
- Install Node.js on Linux/Ubuntu/CentOS
- Node.js First Example
- Node.js Console
- Node.js REPL
- Node.js Package Manager
- Node.js Command Line Options
- Node.js Global Objects
- Node.js OS
- Node.js Timer
- Node.js Errors
- Node.js DNS
- Node.js Net
- Node.js Crypto
- Node.js TLS/SSL
- Node.js Debugger
- Node.js Process
- Node.js Child Process
- Node.js Buffers
- Node.js Streams
- Node.js File System (FS)
- Node.js Path
- Node.js StringDecoder
- Node.js Query String
- Node.js ZLIB
- Node.js Assertion Testing
- Node.js V8
- Node.js Callbacks
- Node.js Events
- Node.js Punycode
- Node.js TTY
- Node.js Web Module
- NestJS
Node.js MySQL
Node.js MongoDB
Nodejs Difference
Node.js MCQ
Node.js Express
Nodejs Interview Questions
Node.js Query String
The Node.js Query String provides methods to deal with query string. It can be used to convert query string into JSON object and vice-versa.
To use query string module, you need to use require('querystring').
Node.js Query String Methods
The Node.js Query String utility has four methods. The two important methods are given below.
Method | Description |
---|---|
querystring.parse(str[, sep][, eq][, options]) | converts query string into JSON object. |
querystring.stringify(obj[, sep][, eq][, options]) | converts JSON object into query string. |
Node.js Query String Example 1: parse()
Let's see a simple example of Node.js Query String parse() method.
File: query-string-example1.js
- querystring = require('querystring');
- const obj1=querystring.parse('name=sonoo&company=javatpoint');
- console.log(obj1);
Node.js Query String Example 2: stringify()
Let's see a simple example of Node.js Query String stringify() method.
File: query-string-example2.js
- querystring = require('querystring');
- const qs1=querystring.stringify({name:'sonoo',company:'javatpoint'});
- console.log(qs1);