Unable to extract JSON fields from tMongoDBInput using tExtractJSONFields

Highlighted
Five Stars SmS
Five Stars

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!


Accepted Solutions
Five Stars SmS
Five Stars

Re: Unable to extract JSON fields from tMongoDBInput using tExtractJSONFields

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.


All Replies
Forteen Stars

Re: Unable to extract JSON fields from tMongoDBInput using tExtractJSONFields

I have read the Json file with JsonPath using tFileInputJson.

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Forteen Stars

Re: Unable to extract JSON fields from tMongoDBInput using tExtractJSONFields

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

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Five Stars SmS
Five Stars

Re: Unable to extract JSON fields from tMongoDBInput using tExtractJSONFields

I was giving "$" as json looppath query.

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

Five Stars SmS
Five Stars

Re: Unable to extract JSON fields from tMongoDBInput using tExtractJSONFields

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.

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Put Massive Amounts of Data to Work

Learn how to make your data more available, reduce costs and cut your build time

Watch Now

How OTTO Utilizes Big Data to Deliver Personalized Experiences

Read about OTTO's experiences with Big Data and Personalized Experiences

Blog

Talend Integration with Databricks

Take a look at this video about Talend Integration with Databricks

Watch Now