Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
mmctony
Contributor
Contributor

From table row to MongoDB

Hi,

I'm using Open Studio for Big Data 8.0 and I'm a newbie.

I have to import data from a SQL table into MongoDB.

A row is strutured like

0695b00000PKpJ1AAL.png 

and target JSON/Mongo structure is like

 

{

  "_id": 1,

  "child1": {

    "id": "c1";

    "name": "Name1"

  },

  "child2": {

    "id": "c2";

    "name": "Name2"

  },

  "objArray": [{

      "id": "a1",

      "name": "aName1"

    }, {

      "id": "a3",

      "name": "aName3"

    }

  ],

  "objIdsArr": ["a1", "a3"]

}

 

The tricky part I see is having two arrays in the target JSON document (objIdsArr, objArray)

that have to be built from a single table row and based on fields that can be null (i.e. rootArray2Id,

rootArray2Name).

 

I had a look at forum posts with examples of tWriteJsonField, I read the doc about tMongoDbOutput.

However it seems to me these components cannot implement directly my transformation.

Should I go for tJavaRow and use org.json stuff i.e. JSONObject, JSONArray to implement the transformation?

 

After building a JSONObject, can tMongoDBOutput handle it directly? How do I setup the final map inside?

 

Thanks for your help,

Michael

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hello,

 

In tMongoDBOutput component in Advanced Settings you can enable the option "Generate JSON Document" and can click on Configure JSON Tree option, inside which you can create your own JSON format as needed. On how to configure the JSON Tree(consisting of different datatypes and objects ), you can refer the below link.

 

https://help.talend.com/r/en-US/8.0/processing/configuring-a-json-tree

 

View solution in original post

1 Reply
Anonymous
Not applicable

Hello,

 

In tMongoDBOutput component in Advanced Settings you can enable the option "Generate JSON Document" and can click on Configure JSON Tree option, inside which you can create your own JSON format as needed. On how to configure the JSON Tree(consisting of different datatypes and objects ), you can refer the below link.

 

https://help.talend.com/r/en-US/8.0/processing/configuring-a-json-tree