从单个 REST 服务响应中读取多个 JSON 并放入数据库 Table - Talend
Read multiple JSONs from single REST Service response and put to Database Table - Talend
我搜索了很多但没有找到确切的解决方案。
我有一个 REST 服务,作为响应,我得到行和 JSON 中的每一行,如下所示:
{"event":"click1","properties":{ "time":"2 dec 2018","clicks":29,"parent":"jbar","isLast":"NO"}}
{"event":"click2","properties":{ "time":"2 dec 2018","clicks":35,"parent":"jbar3","isLast":"NO"}}
{"event":"click3","properties":{ "time":"2 dec 2018","clicks":10,"parent":"jbar2","isLast":"NO"}}
{"event":"click4","properties":{ "time":"2 dec 2018","clicks":9,"parent":"jbar1","isLast":"YES"}}
每一行都是一个JSON(彼此相似)。我有一个数据库 table,所有这些字段都作为列。我想遍历这些并上传 Talend 中的所有数据。我尝试过的如下:
tRestClient--tNormalize--tExtractJsonFields--tOracleOutput
并在 tExtractJsonFields 组件中提供了循环条件和映射,但它不起作用并向我抛出错误提示“json 不能为空或为空 "
在这方面需要帮助。
由于您的网络服务 returns 响应中有多个 json 对象,因此它无效 json 而是一个 json 文档。
您需要将其分解为单独的 json 个对象。
您可以在 tRESTClient
和 tExtractJsonFields
之间添加一个 tNormalize
,并在“\n”字符上规范化 json 文档。
错误“json can not be null or empty
”是由于您的 Jsonpath 查询中的错误。您必须将循环查询设置为“$
”,并使用“event
”、“properties.time
”
引用 json 属性
你能试试这个吗:
在您的 tExtractJsonFields 中,将 属性 readBy 配置为 JsonPath 而无需循环
{"event":"click1","properties":{ "time":"2 dec 2018","clicks":29,"parent":"jbar","isLast":"NO"}}
{"event":"click2","properties":{ "time":"2 dec 2018","clicks":35,"parent":"jbar3","isLast":"NO"}}
{"event":"click3","properties":{ "time":"2 dec 2018","clicks":10,"parent":"jbar2","isLast":"NO"}}
{"event":"click4","properties":{ "time":"2 dec 2018","clicks":9,"parent":"jbar1","isLast":"YES"}}
每一行都是一个JSON(彼此相似)。我有一个数据库 table,所有这些字段都作为列。我想遍历这些并上传 Talend 中的所有数据。我尝试过的如下:
tRestClient--tNormalize--tExtractJsonFields--tOracleOutput
并在 tExtractJsonFields 组件中提供了循环条件和映射,但它不起作用并向我抛出错误提示“json 不能为空或为空
由于您的网络服务 returns 响应中有多个 json 对象,因此它无效 json 而是一个 json 文档。
您需要将其分解为单独的 json 个对象。
您可以在 tRESTClient
和 tExtractJsonFields
之间添加一个 tNormalize
,并在“\n”字符上规范化 json 文档。
错误“json can not be null or empty
”是由于您的 Jsonpath 查询中的错误。您必须将循环查询设置为“$
”,并使用“event
”、“properties.time
”
你能试试这个吗:
在您的 tExtractJsonFields 中,将 属性 readBy 配置为 JsonPath 而无需循环