TRest and draw JSON using tExtractJSONField with TALEND

I am new to Talend and I am stuck in getting JSON data using tRest.

Suppose I'm trying to get all the messages from social networks.

This is why I use https://tagboard.com to get JSON formatted data.

Here is one of the scripts I tried. I have JSON output similar to this from https://post-cache.tagboard.com/search/tunisie?count=2 with two posts as an example, I deleted some nodes to clarify ...:

{ "posts": [ { "network": "twitter", "post_id": "547835328170823680", "text": "#tunisie .. #tunis", "html": " ", "permalink": " ", "post_time": 1419449095, "user_id": "159415522", "user_name": " ", "user_real_name": " ", "user_profile_image_url": " ", "hashtags": [ "tunisie", "tunis" ] }, { "network": "Facebook", "post_id": "547835328170823680", "text": "#tunisia .. #tunis", "html": " ", "permalink": " ", "post_time": 1777449095, "user_id": "159995522", "user_name": " ", "user_real_name": " ", "user_profile_image_url": " ", "hashtags": [ "tunisia", "tunis2" ] } ] } 

Here is the first work of Talend:

enter image description here

And I configured tExtractJSONField to extract the text field from the following data:

enter image description here

enter image description here

Actually I need these fields: newtork, text, post_time and a list of hashtags .

Due to the Body in the mapping table, I think I cannot add more attributes to display the rest of the fields.

I found there a way to map data using tXMLMap, where the body field can be expanded to add more fields:

enter image description here

I believe there is a way for JSON to do the same, but I don’t know how I am waiting for your help.

+5
source share
2 answers

You must use the tMap component enter image description here

And you have to set up the data scheme, as in this example:

enter image description here

+2
source

Select options below

Read: JsonPath

Loop json query: "$ .posts [*]"

Retrieve the internal fields of the json array using [0].network and [1].network in tExtractJSONFields .

0
source

Source: https://habr.com/ru/post/1209855/


All Articles