ljharb/qs

qs.stringify(json) and qs.parse(json) Results are inconsistent with expectations

Open

#471 opened on May 5, 2023

View on GitHub
 (4 comments) (0 reactions) (0 assignees)JavaScript (744 forks)batch import
bughelp wanted

Repository metrics

Stars
 (8,015 stars)
PR merge metrics
 (Avg merge 6d 22h) (2 merged PRs in 30d)

Description

When my json is like this

[
    {
        "fansUid": "",
        "masterShopId": 0,
        "items": [
            {
                "itemId": "",
                "skus": [
                    {
                        "price": 0,
                        "skuId": 0,
                        "promotionToolCode": ""
                    }
                ]
            }
        ],
        "scene": ""
    }
]

i use qs.stringify(json) and qs.parse(json) . but result is

[
    {
        "fansUid": "",
        "masterShopId": "0",
        "items": [
            {
                "itemId": "",
                "skus": [
                    {
                        "[price]": "0",
                        "[skuId]": "0",
                        "[promotionToolCode]": ""
                    }
                ]
            }
        ],
        "scene": ""
    }
]

It was obvious that this was a mistake. How should I solve it

I tried to change multiple versions as well, but the latest version still did not fix the problem.

Contributor guide