gpt4 book ai didi

javascript - 使用 Prototype 将字符串转换为 JSON 数组?

转载 作者:行者123 更新时间:2023-11-28 09:47:04 24 4
gpt4 key购买 nike

我有这个 json 字符串:

{"17":{"31":{"price":5,"oldPrice":5,"priceValue":"5.0000","type":"fixed","excludeTax":5,"includeTax":5},"29":{"price":8,"oldPrice":8,"priceValue":"8.0000","type":"fixed","excludeTax":8,"includeTax":8},"30":{"price":10,"oldPrice":10,"priceValue":"10.0000","type":"fixed","excludeTax":10,"includeTax":10}},"12":{"price":0,"oldPrice":0,"priceValue":"0.0000","type":"fixed","excludeTax":0,"includeTax":0},"11":{"price":0,"oldPrice":0,"priceValue":"0.0000","type":"fixed","excludeTax":0,"includeTax":0}}

如何使用 Prototype 将其转换为数组?我尝试了 evalJSON(),但没有成功。

最佳答案

内置JSON.parse应该这样做,你不需要任何库:

var obj = JSON.parse(jsonString);

关于javascript - 使用 Prototype 将字符串转换为 JSON 数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11653007/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com