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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Parikhharshal
Creator III
Creator III

Shows null values for tExtractJasonFields

Hi there

 

I have designed my job like below which shows result as NULL. I am sure my tExtractjsonFields is not configured properly.

 

0683p000009M134.png

 

Trying to extract Json (as shown below) using URL:

 

[
  {
    "assignment_id": 1234,
    "title": "Assignment 1",
    "points_possible": 10,
    "due_at": "2012-01-25T22:00:00-07:00",
    "unlock_at": "2012-01-20T22:00:00-07:00",
    "muted": false,
    "min_score": 2,
    "max_score": 10,
    "median": 7,
    "first_quartile": 4,
    "third_quartile": 8,
    "module_ids": [
        1,
        2
    ],
    "submission": {
      "submitted_at": "2012-01-22T22:00:00-07:00",
      "score": 10
    }
  },
  {
    "assignment_id": 1235,
    "title": "Assignment 2",
    "points_possible": 15,
    "due_at": "2012-01-26T22:00:00-07:00",
    "unlock_at": null,
    "muted": true,
    "min_score": 8,
    "max_score": 8,
    "median": 8,
    "first_quartile": 8,
    "third_quartile": 8,
    "module_ids": [
        1
    ],
    "submission": {
      "submitted_at": "2012-01-22T22:00:00-07:00"
    }
  }
]

 My tExtractJsonFields is configred as below:

0683p000009M139.png

 

Can someone please guide what am I doing wrong?

 

Thanks

Harshal.

 

Labels (4)
1 Solution

Accepted Solutions
Parikhharshal
Creator III
Creator III
Author

@rhall: This is how my job looks like:

 

0683p000009M1bG.png

 

Where tJavaflex looks like this:

 

Analytics analyticsAPI = new Analytics();

analyticsAPI.parseJsonData(row2.string, (String) globalMap.get("tempFileURI",student_id,sis_user_id,course_id,course_code));

 

It actually calls routine Analytics and returns the output in .csv file which I am then putting into S3 using PutLadedData. Once this job is successful then another subjob runs and copies all the files from S3 to Redshift using below steps:

 

0683p000009M1Fu.png

 

Is there anything I can change or seems correct?

View solution in original post

48 Replies
Parikhharshal
Creator III
Creator III
Author

@rhall and @nthampi:

 

I tried doing with Xpath.

0683p000009M0gQ.png

 

but it shows me error like this:tExtractJSONFields_1 - Unbound prefix: 2018-11-01T18

 

Not sure why it cannot still read.

Anonymous
Not applicable

hi Parikhharshal,

your json path queries does not seem to be correct as per data provided and the requirement 

you better use <"$[*]"> for the loop query.

and then specify the jsonpath for fields.

 

 

 

Regards 

Chandra Kant

Anonymous
Not applicable

@Parikhharshal

If you are using Read By JsonPath, please mention the Loop Jsonpath query as below.

0683p000009M13T.png

 

If you are using Read By Xpath, please mention the Loop Xpath query as below.

0683p000009M0o1.png

Parikhharshal
Creator III
Creator III
Author

@CK395 and @kharindran

 

It works fine. Thanks.

 

Similarly I have got 2 different scenarios:

 

Can you please suggest what should be my Loop jSonpath query in tExtractJsonFields?

 

1. 

{
  "page_views": {
    "2012-01-24T13:00:00-00:00": 19,
    "2012-01-24T14:00:00-00:00": 13,
    "2012-01-27T09:00:00-00:00": 23
  },
  "participations": [
    {
      "created_at": "2012-01-21T22:00:00-06:00",
      "url": "https://canvas.example.com/path/to/canvas",
    },
    {
      "created_at": "2012-01-27T22:00:00-06:00",
      "url": "https://canvas.example.com/path/to/canvas",
    }
  ]
}

 

2. 

{
  "2012-01-24":{
    "instructorMessages":1,
    "studentMessages":2
  },
  "2012-01-27":{
    "studentMessages":1
  }
}

 

Parikhharshal
Creator III
Creator III
Author

@rhall and @manodwhb: Can you pls respond to this?
Anonymous
Not applicable

@Parikhharshal

1. The loop Jsonpath query for this case would be $.participations

2. I am not sure about this as there seems no fixed variable name. Will check on this and update you if I find a solution.

Parikhharshal
Creator III
Creator III
Author

@kharindan: thanks for your reply. What about page_views block which is in point 1.?
Anonymous
Not applicable

Hi,

first of all make your first json file valid,

and since there are no such looping elements thus without looping

for 1 jsonpath query would be :

<"$.pageviews">

<"$.participations[*].created_at">

<"$.participations[*].url">

 

and for 2 jsonpath query would be 

<"$.2012-01-24.instructorMessages">

and similarly for other keys

 

 

 

Regards

Chandra Kant

Parikhharshal
Creator III
Creator III
Author

@CK395 : thanks for the reply. What do you mean by make first json valid? What do I need to do?

Also for the second one, dates keep changing, So I think the way you have setup is going to be hardcoded.

Does it mean for both json queries it should be fairly simple as just bringing fields and get them?