ljharb/qs

Square brackets as object key

Open

#343 aberto em 5 de nov. de 2019

Ver no GitHub
 (12 comments) (0 reactions) (0 assignees)JavaScript (744 forks)batch import
bughelp wantedquestionstringify

Métricas do repositório

Stars
 (8.015 stars)
Métricas de merge de PR
 (Mesclagem média 6d 22h) (2 fundiu PRs em 30d)

Description

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?

Guia do colaborador