Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/felipelavinz/url-unserialize
Serialize and unserialize objects to URL
https://github.com/felipelavinz/url-unserialize
Last synced: 10 days ago
JSON representation
Serialize and unserialize objects to URL
- Host: GitHub
- URL: https://github.com/felipelavinz/url-unserialize
- Owner: felipelavinz
- License: mit
- Created: 2019-03-17T01:42:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T17:58:38.000Z (almost 2 years ago)
- Last Synced: 2024-10-17T08:51:51.849Z (20 days ago)
- Language: JavaScript
- Homepage:
- Size: 1.76 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# URL Unserializer
Convert an object to query string or vice versa.
Strongly opinionated, and probably very custom for a wide use.
Modularized mostly for testing purposes.
## Examples
A simple query string it's converted to an object.
Input:
`foo=bar&lorem=ipsum`
Output:
``` json
{
"foo": "bar",
"lorem": "ipsum"
}
```Multi-dimensional array or objects
Input:
`foo=bar&lorem[ipsum]=dolor`
Output:
```json
{
"foo": "bar",
"lorem": {
"ipsum": "dolor"
}
}
```Numbers are always converted to arrays
Input:
`foo=1,2&lorem[ipsum]=dolor&quick=1`
Output:
```json
{
"foo": [ 1, 2 ],
"lorem": {
"ipsum": "dolor"
},
"quick": [ 1 ]
}
```Check `index.test.js` for a few more examples.