简体   繁体   English

使用 Azure 数据工厂从 REST API 读取 JSON

[英]Read JSON from rest API as is with Azure Data Factory

I'm trying to get Azure Data Factory to read my REST API and put it in SQL Server.我正在尝试让 Azure 数据工厂读取我的 REST API 并将其放入 SQL Server。 The source is a REST API and the sink is a SQL Server table.源是 REST API,接收器是 SQL Server 表。

I tried to do something like:我试图做这样的事情:

"translator": {
    "type": "TabularTranslator",
    "schemaMapping": {
        "$": "json"
    },
    "collectionReference": "$.tickets"
}

The source looks like:来源看起来像:

{ "tickets": [ {... }, {...} ] }

Because of the poor mapping capabilities I'm choosing this path.由于映射能力较差,我选择了这条路径。 I'll then split the data with a query.然后我将使用查询拆分数据。 Preferbly I'd like to store each object inside tickets as a row with JSON of that object.最好我想将每个对象作为带有该对象的 JSON 的一行存储在票证中。

In short, how can I get the JSON output from the RestSource to a SqlSink single column text/nvarchar(max) column?简而言之,如何将 JSON 输出从 RestSource 获取到 SqlSink 单列 text/nvarchar(max) 列?

I managed to solve the same issue by modifying mapping manually.我通过手动修改映射设法解决了同样的问题。 ADF anyway tries to parse json, but from the Advanced mode you can edit json paths. ADF 无论如何都会尝试解析 json,但是在高级模式中您可以编辑 json 路径。 Ex., this is the original schema parsed automatically by ADF https://imgur.com/Y7QhcDI Once opened in Advanced mode it will show full paths by adding indexes of the elements, something similar to $tickets[0][] etc Try to delete all other columns and keep the only one $tickets (the highest level one), in my case it was $value https://i.stack.imgur.com/WnAzC.jpg .例如,这是 ADF 自动解析的原始模式https://imgur.com/Y7QhcDI一旦在高级模式下打开,它将通过添加元素的索引来显示完整路径,类似于 $tickets[0][] 等尝试删除所有其他列并保留唯一一个 $tickets(最高级别的),在我的情况下它是 $value https://i.stack.imgur.com/WnAzC.jpg As the result the entire json will be written into the destination column.结果整个 json 将被写入目标列。

If there are pagination rules in place, each page will be written as a single row.如果有分页规则,每一页将被写成一行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM