Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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 ( 0683p000009MPcz.png ).
Sincerely,
Morgan
Labels (3)
2 Replies
Anonymous
Not applicable
Author

Hi,
Could you please post  your job setting screenshots into forum?
Best regards
Sabrina
Anonymous
Not applicable
Author

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 !