Behavior of the tExtractJSONFields component

Behavior of the tExtractJSONFields component

Hi,
For my process, I need to update the content of a json object, and pass along some other information to handle it later
{ 
   "user" : {
       "lastname" : "TEST",
       "firstname" : "first"        
   },
   "likes" :
       }
   ]
}

From this example, the content that need to be update are the fields "numberOfLike", and also the array relatedPage (I want to replace the full array with an other one).
I try (without no idea how to do better) to reconstruct my object :
tExtractJSONField_1   --   tWriteJSONField  -- tExtractJSONField_2
In tExtractJSONField_1, I get the content of my json object that need to be reused ("user","code","name"), and pass my new field ("numberOfLike", "RelatedPages", and also my other field for further purpose)
In tWriteJSONField, I construct a new object :
{
"jsonObject" : {
"user" : {
"lastname" : "TEST",
"firstname" : "first"        
},
"likes" :
}
]
},
"object1" : "purpose1"
}

In my last tExtractJSONField_2, I separate my field to get my new "jsonObject" with the new info, and the "object1".
When I put the jsonObject in my Collection, the field are not in the same order.
Is there an explanation ? Or did I miss something ? (It's just for clarity, the data are still usable).
Also, is there a better way to update the content of a json object directly in talend ? In my real case test, I have ~40 fields, and if I add some more, I'll need to modify this job just to add the content ( Smiley Sad ).
Sincerely,
Morgan
Moderator

Re: Behavior of the tExtractJSONFields component

Hi,
Could you please post  your job setting screenshots into forum?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

Re: Behavior of the tExtractJSONFields component

Hi, nevermind, i found my problem.
Using tJSONExtract with the JSONPath setting doesn't guarantee the order, contrary to the XPATH setting. It's just annoying to use XPATH since it's not seems to be the best one for nested array in json !
Thanks !