Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Unable to extract JSON fields from tMongoDBInput using tExtractJSONFields

Hi,

 

I've been trying to extract JSON fields from my tMongoDBInput (documents from a mongo collection) using a tExtractJSONFields component, but I'm unable to use it.

 

Logging the output shows :

A JSONObject text must begin with '{' at character 1 of Document{{code=P2.IB.LET, category=PROSECUTION}}

 

My JSON (document) from mongo looks like this:

{ "_id" : { "code" : "P2.IB.LET", "category" : "PROSECUTION" }, "value" : 1 }
{ "_id" : { "code" : "P2.FILECOPY", "category" : "PROSECUTION" }, "value" : 3 }
{ "_id" : { "code" : "SRNT", "category" : "FAI Request" }, "value" : 1 }
{ "_id" : { "code" : "P.399", "category" : "PROSECUTION" }, "value" : 1 }
{ "_id" : { "code" : "REIS.REVFORM", "category" : "PROSECUTION" }, "value" : 4 }

 

I've attached screenshots of my settings and the output as well.

I've tried using Json path as well as Xpath giving similar output (json path just gives a blank output).

 

I need to use tExtractJSONFields for a few other use cases as well, so it's really important that I can get this working.

Any help would be greatly appreciated.

Thanks!

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I resolved the issue.

 

The problem was with the mongo driver version I used in Talend.

I changed the DB version setting in tMongoDBConnection from 3.5.X to 3.2.X and it's working fine now.

Just for note, my MongoDB version is 3.6.2.

View solution in original post

6 Replies
manodwhb
Champion II
Champion II

I have read the Json file with JsonPath using tFileInputJson.

manodwhb
Champion II
Champion II

what are you giving in Loop Jsonpath query ,in tExtractJSONFields?

Anonymous
Not applicable
Author

I was giving "$" as json looppath query.

It's working fine now, the settings/parameters were all fine. I'm posting the answer.

Anonymous
Not applicable
Author

I resolved the issue.

 

The problem was with the mongo driver version I used in Talend.

I changed the DB version setting in tMongoDBConnection from 3.5.X to 3.2.X and it's working fine now.

Just for note, my MongoDB version is 3.6.2.

Anonymous
Not applicable
Author

thanks 

kanuparthy
Contributor
Contributor

Can I have sample code to extract array objects from mongodb input