https://github.com/evaisse/dart_http_query_string
A RFC1738 / RFC1867 compliant query string encoder and decoder, compatible with the PHP & jQuery traditional syntax for nested array/objects, and multidimensional arrays
https://github.com/evaisse/dart_http_query_string
dart http json
Last synced: about 1 month ago
JSON representation
A RFC1738 / RFC1867 compliant query string encoder and decoder, compatible with the PHP & jQuery traditional syntax for nested array/objects, and multidimensional arrays
- Host: GitHub
- URL: https://github.com/evaisse/dart_http_query_string
- Owner: evaisse
- License: mit
- Created: 2022-05-02T12:10:17.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-10-19T09:56:40.000Z (over 3 years ago)
- Last Synced: 2025-11-27T17:11:33.957Z (4 months ago)
- Topics: dart, http, json
- Language: Dart
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# http_query_string
[](https://github.com/evaisse/dart_http_query_string/actions)
[](https://codecov.io/gh/evaisse/dart_http_query_string)
A RFC1867 compliant query string encoder and decoder, compatible with the PHP & jQuery traditional syntax for nested array/objects.
Inspired by :
- PHP function [`http_build_query()`](https://www.php.net/manual/en/function.http-build-query.php) & [`parse_str()`](https://www.php.net/manual/en/function.parse-str.php)
- nodejs [`qs` package](https://www.npmjs.com/package/qs)
```dart
import 'package:http_query_string/http_query_string.dart';
void main() {
var decoder = Decoder();
print(decoder.convert("foo=bar&list%5B0%5D=bar&list%5B1%5D=foo&list%5B2%5D%5Bkey%5D=value"));
}
```
Will print out something like that
```json
{
"foo": "bar",
"list": [
"bar",
"foo",
{"key": "value"}
]
}
```
And vice versa :
```dart
import 'package:http_query_string/http_query_string.dart';
void main() {
print(Encoder().convert({
"encode": "bar with space",
"int": 42,
"float": 42.367,
"negative": -23,
"true": true,
"false": false,
"null": null,
"set": {"a", "b"},
"list": [
"bar",
"foo",
],
"map": {
"key": "value"
},
}));
}
```
Will output
````
'encode=bar+with+space&int=42&float=42.367&negative=-23&true=1&false=0&set%5B0%5D=a&set%5B1%5D=b&list%5B0%5D=bar&list%5B1%5D=foo&map%5Bkey%5D=value'
````