-1
JSON을 파싱하는 일부 자바 스크립트 코드가 있는데 o.products 및 cp.key에서 "options"및 "childProducts"데이터를 가져 오려고합니다. 끝없는 문자열 파싱없이 효율적으로이 작업을 수행 할 수있는 방법이 있습니까?Javascript, JSON에서 데이터 추출
var spConfig = new Product.Config(
{"attributes":{
"451":{
"id":"451",
"code":"package_size",
"label":"Package size",
"options":[
{"id":"4",
"label":"1 lb.",
"oldPrice":"0",
"products":["4562"],
"brewsaver":"1"},
{"id":"62",
"label":"1 lb. crushed",
"oldPrice":"0",
"products":["4649"],
"brewsaver":"1"},
{"id":"14",
"label":"55 lbs.",
"oldPrice":"0",
"products":["704"],
"brewsaver":null}
]
}
},
"template":"$#{price}",
"basePrice":"1.75",
"oldPrice":"1.75",
"productId":"3390",
"chooseText":"Choose an Option...",
"taxConfig": {
"includeTax":false,
"showIncludeTax":false,
"showBothPrices":false,
"defaultTax":0,
"currentTax":0,
"inclTaxTitle":"Incl. Tax"
},
"childProducts":
{
"704":
{
"price":"64.99",
"finalPrice":"64.99"
},
"4562":
{
"price":"1.75",
"finalPrice":"1.75"
},
"4649":
{
"price":"1.75",
"finalPrice":"1.75"
}
},
도움 주셔서 감사합니다. 작동 중! 그것에 6 시간을 보낸 후에 (그리고 작동하지 않는), 나는 결국 다른 중괄호가 필요하다는 것을 깨달았다. 거룩한! –
@ JenniferBorn : 좋은 거래, 도움이 된 것을 기쁘게 생각합니다! –