qs 0.0.1-nullsafety.3 copy "qs: ^0.0.1-nullsafety.3" to clipboard
qs: ^0.0.1-nullsafety.3 copied to clipboard

outdated

A query string encoding and encoding library. It's better to use with protobuf(go), gorilla/schema(go) and qs(js).

qs #

Encode json to query string or decode query string to json.

Encode #

import 'package:qs/qs.dart'' as qs;

const json = {
  'key1': 11,
  'key2': 'str',
  'key3': false,
  'key4': 0,
  'key5': {'cKey1': true},
  'key6': [0, 1],
  'key7': [
    {'cKey1': 233},
    {'cKey2': false}
  ]
}

const result = 'key_1=11&key_2=str&key_3=false&key_4=0&key_5.c_key_1=true&key_6=0&key_6=1&key_7.0.c_key_1=233&key_7.1.c_key_2=false';

final encoder = qs.Encoder();
final str = encoder.encode(json);  
// str == result

Decode #

import 'package:qs/qs.dart' as qs;

const str == 'key_1=11&key_2=str&key_3=false&key_4=0&key_5.c_key_1=true&key_6=0&key_6=1&key_7.0.c_key_1=233&key_7.1.c_key_2=false';

const result = {
  'key1': ['11'],
  'key2': ['str'],
  'key3': ['false'],
  'key4': ['0'],
  'key5': {
    'cKey1': ['true']
  },
  'key6': ['1'],
  'key7': [
    {
      'cKey1': ['233']
    },
    {
      'cKey2': ['false']
    }
  ]
};

final decoder = qs.Decoder();
final json = decoder.decode(str);
// json == result
1
likes
0
points
3
downloads

Publisher

verified publisherronbb.fun

Weekly Downloads

A query string encoding and encoding library. It's better to use with protobuf(go), gorilla/schema(go) and qs(js).

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on qs