[Vuejs]-How can inner elements of nested json can be accesed in vuejs

0👍

I don’t know how you want to use your object in your code, since you haven’t posted it, so I am replying to your comment to the best of my ability.

var obj = {
	"time" : "",
  "rates": {
  	"MXN": {
    	"name": "NAME",
      "rate": "RATE"
    },
    "USD": {
    	"name": "NAME",
      "rate": "RATE"
    }
  }
}


function parseRates() {
   if (obj.hasOwnProperty("rates")) {
     var ratesObj = obj.rates;
    
    for(var currency in ratesObj) {
    	if (ratesObj.hasOwnProperty(currency)) {
      	var curr = ratesObj[currency];
      	for(var prop in curr) {
        	if (curr.hasOwnProperty(prop)) {
      		    var p = curr[prop];
      		    console.log(p);
      	       }
            }
          }
  	 }
     }
}

parseRates();

Leave a comment