Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goto-bus-stop/qs-stringify
Simple query stringify with nesting, ~200b gzipped.
https://github.com/goto-bus-stop/qs-stringify
querystring
Last synced: 13 days ago
JSON representation
Simple query stringify with nesting, ~200b gzipped.
- Host: GitHub
- URL: https://github.com/goto-bus-stop/qs-stringify
- Owner: goto-bus-stop
- License: mit
- Created: 2017-09-13T13:07:31.000Z (about 7 years ago)
- Default Branch: default
- Last Pushed: 2024-10-15T20:33:17.000Z (29 days ago)
- Last Synced: 2024-10-24T16:23:21.727Z (20 days ago)
- Topics: querystring
- Language: JavaScript
- Homepage: https://npmjs.com/package/qs-stringify
- Size: 120 KB
- Stars: 20
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# qs-stringify
Simple query stringify with nesting.
[![npm][npm-image]][npm-url]
[![github][github-image]][github-url]
[![standard][standard-image]][standard-url][npm-image]: https://img.shields.io/npm/v/qs-stringify.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/qs-stringify
[github-image]: https://github.com/goto-bus-stop/qs-stringify/workflows/Node%20CI/badge.svg
[github-url]: https://github.com/goto-bus-stop/qs-stringify/actions
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard## Install
```
npm install qs-stringify
```## Usage
```js
var stringify = require('qs-stringify')stringify({
page: {
offset: 50,
limit: 25
},
filter: 'hello world'
})
// → "page[offset]=50&page[limit]=25&filter=hello%20world"
```This module expects that you know the shape of the query string you want to print, and only does trivial serialization of strings, numbers, and nested objects.
If you want to use other types or do custom serialization, fit them into a supported shape first:```js
var stringify = require('qs-stringify')var startAt = new Date()
var filterTags = ['work', 'home']stringify({
tags: filterTags.join(','),
startAt: startAt.toISOString(),
})
// → "tags=work,home&startAt=2024-10-15T20%3A22%3A36.883Z"
```## License
[MIT](LICENSE.md)