Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
fjblau
Contributor
Contributor

Parsing JSON Question

I have the following json response:

{
"2019-06-01":["recs": 1, "vals": 2],
"2019-06-02":["recs": 1, "vals": 2]
}

 

I want the result:

2019-06-01, 1, 2
2019-06-02, 1, 2

 

In the JSONPath I have "$.[*]"


I can get back the values 1,2, but I don't know how to get the date first?

 

I know it must be something stupid easy, but I've tried all sorts of combinations of things and still can't seem to get it!

 

TIA.

 

Frank

Labels (3)
2 Replies
Anonymous
Not applicable

It look's like the correct version of your json should be :

 

{
"2019-06-01":{"recs": 1, "vrec": 2},
"2019-06-02":{"recs": 1, "vals": 2}
}

Another issue is that, "2019-06-01" and "2019-06-02" are like column names, not values

 

Your expected result may require something like :

 

{
	"root":[
		{"date":"2019-06-01","recs": 1, "vals": 2},
	      {"date":"2019-06-02","recs": 1, "vals": 2}
	     ]
}

 

fjblau
Contributor
Contributor
Author

Yah, it's not my API so I don't have any control over it... I can get one day record at a time though, so I guess the best thing is to loop through the days I want data for and pass it as a context variable or something.