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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Basit
Contributor III
Contributor III

Extracting Json Fields always fails

Hi,

 

I am trying to extract some JSON fields after a REST request but somehow I am not able to get the correct values. This is the job:

0683p000009M5PE.png

The value for version in tLogRow_3 is always empty

The JSON looks like this:

{
    "results": [
        {
            "attributes": {
                "name": "myName",
                "description": 0.0,
                "version": 1.0
            }
        }
    ]
}

With tLogRow Talend prints the following:

<?xml version="1.0" encoding="UTF-8"?>
<root><results><attributes><name>myName</name><description>0.0</description><version>1.0</version></attributes></results></root>

Now I want to extract the value for version by using tExtractJSONFields

0683p000009M5SW.png

 

I also get the following error message:

Expected to find an object with property ['results'] in path $ but found 'java.lang.String'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.

 

Talend can't print the value and I don't know what I am doing wrong. Would appreciate any help.

 

Regards,

Basit

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Your problem is with the tRestClient. You need to go to the Advanced Settings and untick "Convert Response To DOM Document". This is used to convert JSON to an XML document. You will also need to switch the column that your tExtractJSONFields component reads to the "string" column. JSON is returned as a String and XML as a Document (body).

View solution in original post

5 Replies
Anonymous
Not applicable

Your response is coming as xml, but you're trying to parse it as json.  Use the http header

Accept: application/json

to get a response in JSON format

Basit
Contributor III
Contributor III
Author

Hi @evansdar,

 

I am already using this header. Somehow tLogRow prints it that way. Don't know why...

I think the issue is something else.

Anonymous
Not applicable

Your problem is with the tRestClient. You need to go to the Advanced Settings and untick "Convert Response To DOM Document". This is used to convert JSON to an XML document. You will also need to switch the column that your tExtractJSONFields component reads to the "string" column. JSON is returned as a String and XML as a Document (body).

Basit
Contributor III
Contributor III
Author

Hi @rhall,

 

you are right! Totally forget about configuring that. I was just focused on the tExtractJSONFields component. Thank you 0683p000009MACn.png

Anonymous
Not applicable

 No problem. It is easily overlooked 🙂