tRest并使用tExtractJSONField和TALEND映射JSON [英] tRest and map JSON with tExtractJSONField with TALEND

查看:108
本文介绍了tRest并使用tExtractJSONField和TALEND映射JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Talend并不陌生,我一直坚持使用tRest获取JSON数据.

I'm quite new to Talend and I am stuck with getting JSON data using tRest.

我们假设我正在尝试从社交网络获取所有帖子.

We Suppose that I am trying to get all posts from social networks.

这就是为什么我使用 https://tagboard.com 来获取以JSON格式格式化的数据的原因.

That's why I am using https://tagboard.com to get data which is formatted in JSON.

这是我尝试过的场景之一. 我有来自 https://post-cache.tagboard的输出JSON数据. com/search/tunisie?count = 2 以2个帖子为例,我删除了一些节点来澄清...:

Here is one of the scenarios I tried. I have an output JSON data like this from https://post-cache.tagboard.com/search/tunisie?count=2 with 2 posts as example, I removed 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" ]        
    }
]
}

这是Talend的第一份工作:

Here's the first Talend job :

然后我将tExtractJSONField配置为从数据中提取 text 字段,如下所示:

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

实际上,我需要这些字段:新闻,文本,邮寄时间 #hashtags 列表.

In fact, I need these fields : newtork, text, post_time, and the list of hashtags.

由于映射表上的正文,我认为我无法添加更多属性来映射其余字段.

Because of Body on the Mapping table, I think I can not add more attributes to map the rest of fields.

我发现有一种使用tXMLMap映射数据的方法,其中可以扩展body字段以添加更多字段:

I found there's a way to map data with tXMLMap where the body field can be extended to add more fields :

我相信有一种方法可以对JSON执行相同的操作,但我不知道该如何做,我在等待您的帮助.

I believe there's a way do the same thing for JSON but I dont know how and I wait for your help.

推荐答案

您必须使用 tMap 组件

您必须像以下示例一样配置数据模式:

And you have to configure data schema like this example :

这篇关于tRest并使用tExtractJSONField和TALEND映射JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆