-1

JSON を解析する Javascript コードがいくつかあり、o.products と cp.key で "options" と "childProducts" のデータを取得したいと考えています。無限の文字列解析なしでこれを効率的に行う方法はありますか?

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"
            }
        },
4

1 に答える 1