Jquery two json objects and sum up
<p>I'm trying to get two objects from one json string and at the end sum those two up. 
I've searched this forum and found different solutions but not a single one which does exactly what I want to achieve. I'm pretty new to Jquery and json so bear me. This is my function:</p>

<pre><code>function bakVormShipping(targetClass){

    $.getJSON('http://shop.com/cart/?format=json', function(data){

        var totals =  // is this correct?
        var methods = // 
        var grandTotal = // totals + methods

        $.each(data.cart.shipping.methods, function(index, methods){
            if (index == "core|10292|40695" || index == "core|10292|40693" || index == "core|10292|40718"){
                $('&lt;strong/&gt;').html('€' + (+methods.price.price_incl).toFixed(2)).appendTo(targetClass); // the shipping price
                $('&lt;strong/&gt;').html('€' + (+totals.grand_total).toFixed(2)).appendTo('.grandTotal'); // the sum of methods.price.price_incl + grand_total
            }
        });
    });
}
</code></pre>

<p>My json string looks like this:</p>

<pre><code>"shipping":"methods":{"core|13490|40699":{"id":"core|13490|40699","title":"ophalen","description":"ophalen","content":false,"pickup":true,"cod":false,"price":{"price_excl":"0.0000","price_incl":"0.0000"}},"core|10292|40695":{"id":"core|10292|40695","title":"Pakketdienst","description":"Pakketdienst","content":false,"pickup":false,"cod":false,"price":{"price_excl":"21.0084","price_incl":"25.0000"}}}}
"totals":{"sub_total":"335.29","taxes":[{"percentage":"0.1900","amount":63.71}],"grand_total":"399.00"}
</code></pre>

<p>I've cut out a lot of irrelevant stuff but the json file works. </p>

<p>As you can see the function calls the shipping method if the index == "blabla". So far so good. My question is how do I add up the JSON string "totals.grand_total" with the shipping costs. On the forum I've found that you can work with variables and then make a simple calculation. Problem is that I don't know how to get the "totals" out of the same JSON file and then add this up with the shipping costs. </p>

<p>Any help greatly appreciated. </p>
