I have a string like this one:
{
"products":{"56":"productName","28":"productName"},
"excludedProducts":{"83":"productName","1":"poductName"}
}
So what I want is to get an object in javascript which looks like this:
{
products: {
"56": "productName",
"28": "productName"
},
excludedProducts: {
"83": "productName",
"1": "productName"
}
}
But JSON.parse() converts numbers into indexes and I get
{
products: {
28: "productName",
56: "productName"
},
excludedProducts: {
83: "productName",
1: "productName"
}
}
So basically, is there a way to preserve order of elements after parsing the string formatted like that?
您需要利用数组来保留格式。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.