ljharb/qs

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

Ouverte

#471 ouverte le 5 mai 2023

 (4 commentaires) (0 réaction) (0 personne assignée)JavaScript (911 forks)batch import
bughelp wanted

Métriques du dépôt

Stars
 (8 943 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

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.

Guide contributeur