ljharb/qs

Square brackets as object key

Offen

#343 geöffnet am 05.11.2019

 (12 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (902 Forks)batch import
bughelp wantedquestionstringify

Repository-Metriken

Stars
 (8.943 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 6T 22h) (2 gemergte PRs in 30 T)

Beschreibung

I have following object:

{
  "filter": {
    "/person[]/email": "test@test"
  }
}

When I use it in query string - at the end the result is not the same object:

qs.stringify(...) // => filter%5B%2Fperson%5B%5D%2Femail%5D=test%40test
qs.parse(...) // => { "filter[/person" : ["test@test"] }

'[]' in object key name is the problem - so I replaced them with another character. But I wanna know - can I somehow escape special characters in cases like this one?

Contributor Guide