Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xwartz/to-query.js
🏁 Serialize a set of key/values into a query string, like ruby to_query method.
https://github.com/xwartz/to-query.js
query ruby
Last synced: 23 days ago
JSON representation
🏁 Serialize a set of key/values into a query string, like ruby to_query method.
- Host: GitHub
- URL: https://github.com/xwartz/to-query.js
- Owner: xwartz
- License: mit
- Created: 2016-10-28T10:45:27.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-28T11:08:26.000Z (about 8 years ago)
- Last Synced: 2024-10-10T01:38:37.733Z (27 days ago)
- Topics: query, ruby
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# to-query.js
Serialize a set of key/values into a query string, like ruby [to_query](http://apidock.com/rails/ActiveSupport/CoreExtensions/Hash/to_query) method.## Usage
ES6:
```js
import toQuery from 'to-query.js'toQuery({ arr: [{ a:1, b: 2 }, { a: 3, b: 4 }] })
// => "arr[][a]=1&arr[][b]=2&arr[][a]=3&arr[][b]=4"toQuery({ arr: [{ a:1, b: 2 }, { a: 3, b: 4 }] }, true)
// => "arr[0][a]=1&arr[0][b]=2&arr[1][a]=3&arr[1][b]=4"toQuery({ a: 'v', b: [1, 2, 3] })
// => "a=v&b[]=1&b[]=2&v[]=3"```
## License
MIT © [xwartz](https://github.com/xwartz)