I have data in the MongoDB database where one of the columns is JSON Array. Now I want to retrieve only the first object from that JSON Array column.
Input_Column :
**[{"id" : "25",
"name" : "spot1" ,
"node" : "start_node",
"order" : "1",
"status" : "completed",
"location" : "gate1"},
{"name" : "spot2",
"order" : "2" },
{ "name" : "spot3",
"node" : "start_node",
"status" : "pending" }]**
Required output_column :
`status:`
completed
I need only the first value from the array. I tried using the tExtractJSONFields component in Talend. And set the JSON loop as "$.status". But I got the output as
`status:`
completed
null
pending
AFTER EDIT :
[{"id" : "25",
"name" : "spot1" ,
"node" : "start_node",
"order" : "1",
"status" : "completed" ,
"location" : "gate1"},
{"name" : "spot2",
"order" : "2" },
{ "name" : "spot3",
"node" : "start_node",
"status" : "pending" } ]
[{"id" : "26",
"name" : "pull1" ,
"node" : "start_node",
"order" : "3",
"status" : "arrived" ,
"location" : "gate3"},
{"name" : "pull2",
"order" : "4" },
{ "name" : "pull3",
"node" : "end_node",
"status" : "pending" } ]
[{"id" : "27",
"name" : "task1" ,
"node" : "start_node",
"order" : "5",
"status" : "pending" ,
"location" : "gate12"},
{"name" : "task2",
"order" : "6" },
{ "name" : "task3",
"node" : "end_node",
"status" : "pending" } ]
expected output :
status
completed
arrived
pending


