Struct serde_qs::Config[][src]

pub struct Config { /* fields omitted */ }
Expand description

To override the default serialization parameters, first construct a new Config.

The strict parameter controls whether the deserializer will tolerate encoded brackets as part of the key. For example, serializing the field a = vec![12] might give a[0]=12. In strict mode, the only string accepted will be this string, whereas in non-strict mode, this can also be deserialized from a%5B0%5D=12. Strict mode is more accurate for cases where it a field may contain square brackets. In non-strict mode, the deserializer will generally tolerate unexpected characters.

A max_depth of 0 implies no nesting: the result will be a flat map. This is mostly useful when the maximum nested depth is known beforehand, to prevent denial of service attacks by providing incredibly deeply nested inputs.

The default value for max_depth is 5, and the default mode is strict=true.

use serde_qs::Config;
use std::collections::HashMap;

let config = Config::new(0, true);
let map: HashMap<String, String> = config.deserialize_str("a[b][c]=1")
                                         .unwrap();
assert_eq!(map.get("a[b][c]").unwrap(), "1");

let config = Config::new(10, true);
let map: HashMap<String, HashMap<String, HashMap<String, String>>> =
            config.deserialize_str("a[b][c]=1").unwrap();
assert_eq!(map.get("a").unwrap().get("b").unwrap().get("c").unwrap(), "1");

Implementations

Create a new Config with the specified max_depth and strict mode.

Deserializes a querystring from a &[u8] using this Config.

Deserializes a querystring from a &str using this Config.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.