简体   繁体   English

Azure 数据工厂 REST API 返回无效 JSON 分页文件

[英]Azure Data Factory REST API return invalid JSON file with pagination

I'm building a pipeline, which copy a response from a API into a file in my storage account.我正在构建一个管道,它将来自 API 的响应复制到我的存储帐户中的一个文件中。 There is also an element of pagination.还有一个分页元素。 However, that works like a charm and i get all my data from all the pages.然而,这就像一个魅力,我从所有页面获取所有数据。

My result is something like this:我的结果是这样的:

 {"data": {
  "id": "Something",
  "value": "Some other thing"
}}

The problem, is that the copy function just appends the response to the file and thereby making it invalid JSON, which is a big problem further down the line.问题是副本 function 只是将响应附加到文件,从而使其无效 JSON,这是一个大问题。 The final output would look like:最终的 output 看起来像:

{"data": {
  "id": "22222",
  "value": "Some other thing"
}}
{"data": {
  "id": "33333",
  "value": "Some other thing"
}}

I have tried everything I could think of and google my way to, but nothing changes how the data is appended to the file and i'm stuck with an invalid JSON file:(我已经尝试了所有我能想到的方法并用谷歌搜索,但没有任何改变数据附加到文件的方式,我被无效的 JSON 文件卡住了:(

As a backup plan, i'll just make a loop and create a JSON file for each PAGE.作为备份计划,我将创建一个循环并为每个 PAGE 创建一个 JSON 文件。 But that seems a bit janky and really slow但这似乎有点简陋而且真的很慢

Anyone got an idea or have a solution for my problem?有人知道我的问题或有解决方案吗?

When you copy data from Rest API to blob storage it will copy data in the form of set of objects by default.当您将数据从 Rest API 复制到 Blob 存储时,它会默认set of objects的形式复制数据。

Example:例子:

sample data
{ "time": "2015-04-29T07:12:20.9100000Z", "callingimsi": "466920403025604"}

sink data
{"time":"2015-04-29T07:12:20.9100000Z","callingimsi":"466920403025604"}
{"time":"2015-04-29T07:13:21.0220000Z","callingimsi":"466922202613463"}
{"time":"2015-04-29T07:13:21.4370000Z","callingimsi":"466923101048691"}

This is the invalid format of Json.这是 Json 的无效格式。

To work around this, select file pattern in sink activity setting as Array of objects this will return array of all objects.要解决此问题,接收器活动中的 select 文件模式设置为Array of objects这将返回所有对象的数组。在此处输入图像描述

Output: Output:

在此处输入图像描述

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

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