Search code examples
talend

How to extract array fields from json field (mongodb) with 'textractjsonfield' and why rows are passed but not showed in the 'tlog'


I have a collection named 'collaborators' in nosql database (mongodb), enter image description here I want to extract the first row of the array 'contracts' with 'textractjsonfield', rows are passed but not showed, why ? enter image description here This is the component config, enter image description here enter image description here

JSONpath enter image description here

i want some informations about the component config

.............................................

this is the 'contracts' field data with 'tlogrow' enter image description here this is the output of the job with 'textractjsonfield' [enter image description here][3] and this is the configuration of 'textractjsonfield' component [enter image description here][4]


while creating "$oid" ddddd enter image description here


this is the table config and the tlogrow output enter image description here


Solution

  • So for the issue, the problem was the path to the array.

    The easiest solution is to change the JSONPath option to Xpath and set the loop to "/" and the Xpath request to "." :

    enter image description here

    So if you have data like this [test1,test2,test3] , you can have an issue processing it so first I processed it in a tMap to make it usable by a tExtractJSONFields

    enter image description here

    (the content.toString() is because of the way I read the sample data, it's unecessary for the base problem) and the

    .replaceAll("\\[", "\\[\"").replaceAll("\\]", "\"\\]").replaceAll(",", "\",\"")
    

    Is to make the string / array usable by the tExtractJSONFields.

    And then with the configuration of the tExtractJSONFields, you have this output

    enter image description here