ljharb/qs

Square brackets as object key

開放

#343 建立於 2019年11月5日

 (12 則留言) (0 個反應) (0 位負責人)JavaScript (911 個分叉)batch import
bughelp wantedquestionstringify

倉庫指標

星標
 (8,943 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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?

貢獻者指南