My question is i recive this but in string
obj = {"rnc": "44444044444",
"cliente": "EMPRESA S.A.",
"ncf": "1234567890123456789",
"ncf_ref": "0987654321098765432",
"tipo": "FacturaConsumidorFinal", # Ver clase ReceiptEnum para valores permitidos
"logo": false,
"lineas": [{
"descripcion": ["Linea 1", ..., "Linea 10"],
"cantidad": 2,
"importe": 12.00,
"itbis": 13.0,
"tipo_pago": "LineaVenta", # Ver clase ReceiptItemEnum para valores permitidos
"qtyxprice": True,
"promocion": False"
}],
"pagos": [{
"tipo": 1, # valor entre 1 y 14, según tipos de pago configurados
"importe": 1200.00,
"cancelado": False,
"descripcion": ["linea 1", "linea 2", "lines 3"],
}],
"descuentos": [{ # descuento o recargo global
"descripcion": "lalalala",
"importe": 1200.00
}],
"densidad": "ppp180x180" # ver clase PrinterDensity para valores permitidos
}
I convert to dictionary using
import ast
linea = ast.literal_eval(obj)
im trying to read inside lineas['importe'] to change value 12.00 to 1200 of course using int, i know how to do it, just gonna multiply for 100 for example
#12.00
int(12.00*100) = 1200 #they always need to end with '00'
int(2*100) = 200
but i dont know how to get there the same with linea['itbis]..pagos['importe'] and descuentos['importe'] and the end it will output like this.
{"rnc": "44444044444",
"cliente": "EMPRESA S.A.",
"ncf": "1234567890123456789",
"ncf_ref": "0987654321098765432",
"tipo": "FacturaConsumidorFinal", # Ver clase ReceiptEnum para valores permitidos
"logo": false,
"lineas": [{
"descripcion": ["Linea 1", ..., "Linea 10"],
"cantidad": 2,
"importe": 1200, #<----- here(12.00)
"itbis": 1300, #<----- here(13.00)
"tipo_pago": "LineaVenta", # Ver clase ReceiptItemEnum para valores permitidos
"qtyxprice": True,
"promocion": False"
}],
"pagos": [{
"tipo": 1, # valor entre 1 y 14, según tipos de pago configurados
"importe": 120000, #<----- here (1200.00)
"cancelado": False,
"descripcion": ["linea 1", "linea 2", "lines 3"],
}],
"descuentos": [{ # descuento o recargo global
"descripcion": "lalalala",
"importe": 120000 #<----- here (1200.00)
}],
"densidad": "ppp180x180" # ver clase PrinterDensity para valores permitidos
}
I was trying to
for k,v in obj.items():
for thing in v:
print v
but i got an error and the end Traceback (most recent call last): File "", line 2, in TypeError: 'bool' object is not iterable
well Thanks for read this long explanation x_X