ljharb/qs

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

オープン

#471 opened on 2023/05/05

 (4 件のコメント) (0 件のリアクション) (0 人の担当者)JavaScript (911 件のフォーク)batch import
bughelp wanted

Repository metrics

Stars
 (8,943 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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.

コントリビューターガイド