I have a value customer with different condition :
You did not check null for customer
var customer = json.fields.customer != null && json.fields.customer.length > 0 ? json.fields.customer[0].value : null;