ljharb/qs

Arrays parsed incorrectly

Open

#288 创建于 2018年11月27日

在 GitHub 查看
 (3 评论) (3 反应) (0 负责人)JavaScript (8,015 star) (744 fork)batch import
feature requesthelp wantedparse

描述

Hi, I have this object:

const filter = {
  3: [{ name: 'Test', id: 50753 }, { name: 'Test2', id: 48464 }],
  6: ['2018-11-01', '2018-11-02']
}

I call stringify and parse

const stringifyQuery = Qs.stringify(filter, { arrayFormat: 'brackets' })
const parseQuery = Qs.parse(stringifyQuery, { arrayLimit: 0 })

Result parse: Key '3' contains only 1 element instead of 2. And this element contains the merged keys name, id:

3: Array(1)
  0:
    id: (2) ["50753", "48464"]
    name: (2) ["Test", "Test2"]

I expect:

3: Array(2)
  0: {name: "Test", id: 50753}
  1: {name: "Test2", id: 48464}

Please help me https://codepen.io/anon/pen/rQrqXx

贡献者指南

Arrays parsed incorrectly · ljharb/qs#288 | Good First Issue