[Vuejs]-Vue JS: how to get nested JSON data

0👍

find.payment.cash_payment.paid_amount
find.payment.installment_payment.installments[0].paid_amount
find.payment.installment_payment.installments[1].paid_amount

You will need a method to detect the payment method and also sum the installments if it is an array.

Non tested example

getPaidAmount(flat) {
 if (flat.payment.cash_payment){ return Number(payment.cash_payment.paid_amount) }
 if (flat.payment.installment_payment){ 
   const arr = flat.payment.installment_payment.installments.map(it=>Number(it.paid_amount))
   const sum = arr.reduce(function (a, b) {return a + b;}, 0);
   return sum
  }
}

Leave a comment