Cannot display data key from simple Json

(Augusto Vera) #1

I am receiving this simple Json from a HTTP request:

{
“FechaCreacion”: “2016-11-30”,
“Monto”: “210.00”,
“Concepto”: “Anticipo a pedido No. 04440”,
“NoDocto”: 6661
},
{
“total”: “210.00”
}

I can display the raw body, but when trying to display for example the “total” key it does not show, nor any other, :point_right: here is an example of the message block.

Thanks in advance for tour help.

(Nathan Stults) #2

That does not appear to be a valid JSON payload - you have two objects there - are they wrapped in a array that you are now showing? If so, then you would need to make sure you address the correct element in the array.

(Augusto Vera) #3

This is the output of the http request:

Status Code
200
Body
[{“FechaCreacion”: “2016-11-30”, “Monto”: “210.00”, “Concepto”: “Anticipo a pedido No. 04440”, “NoDocto”: 6661}, {“total”: “210.00”}]
Data
[
{
“FechaCreacion”: “2016-11-30”,
“Monto”: “210.00”,
“Concepto”: “Anticipo a pedido No. 04440”,
“NoDocto”: 6661
},
{
“total”: “210.00”
}
]

And at the message block I am adressing it like this:

The output looks like this:

#4

I think you should try it like that:
data__1__total

(Augusto Vera) #5

Works when the first set of keys the number of records is just 1, whenever there are more records in the first set of keys it does not.

#6

You could use the Code action to get it.

var body = {{consulta_4_http_request.body}};
var total = body[body.length-1].total;
resolve(total);