Skip to main content

parse

Function parse 

Source
pub fn parse(value: &str) -> Option<HashMap<String, Value>>
Expand description

Parses a query string into a map of key-value pairs.

Returns None if:

  • The query string is malformed
  • Nesting depth exceeds 5 levels

ยงExamples

use hitbox_http::query::parse;

let params = parse("page=1&sort=name").unwrap();
assert_eq!(params.get("page").unwrap().inner(), vec!["1"]);
assert_eq!(params.get("sort").unwrap().inner(), vec!["name"]);

// Exceeds depth limit
assert!(parse("a[b][c][d][e][f][g]=1").is_none());