Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Parsing a JSON from trestclient response

Hello Everybody,

 

I need to parse a JSON from  TrestClient and save the data into a table. 

This is an example of my JSON:

{"eventi_carichi":[{
"codice_base":"6111",
"id_evento":0,
"data_viaggio":"2020-01-24T00:00:00",
"numero_viaggio":293137,
"nome_autista":"MARIO",
"motrice":"AAA123",
"rimorchio":"BBB456",
"ora_inizio":"07:33:05",
"ora_fine":"07:44:38",
"durata":693,
"codice_prodotto":"SSP",
"litri_programmati":9000,
"litri_erogati":9001,
"litri15_erogati":9087,
"densita_ambiente":0.0,
"densita15":0.7247
},
{"codice_base":"6111",
"id_evento":0,
"data_viaggio":"2020-01-24T00:00:00",
"numero_viaggio":293137,
"nome_autista":"CARLO",
"motrice":"CCC987",
"rimorchio":"DDD856",
"ora_inizio":"07:33:05",
"ora_fine":"07:51:26",
"durata":1101,
"codice_prodotto":"GAS",
"litri_programmati":27000,
"litri_erogati":27003,
"litri15_erogati":27011,
"densita_ambiente":0.0,
"densita15":0.841}
]
}

 

this is how i'm trying to do it:

 

0683p000009M8sh.png

 

0683p000009M8sm.png

But I am getting the following error:

JSONObject text must begin with '{' at character 1 of "{\"eventi_carichi\":[{\"codice_base\":.....

 

Any ideas?? I'm going crazy!

Labels (4)
1 Reply
Anonymous
Not applicable
Author

You appear to be using XPath for this. It might be easier to use JsonPath and set your loop to.....

"$.eventi_carichi[*]"

If you are regularly working with JSON it makes sense not to rely on XPath. There are certain pieces of functionality that do not translate between JSONPath and XPath.