JSON源数据:读取JSON数组 [英] JSON source data: Reading JSON arrays

查看:84
本文介绍了JSON源数据:读取JSON数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一组JSON文档,每个文档都有JSON数组作为子属性,我需要对其进行展平和迭代.搜索完文档后,Cosmos数据集类型似乎不支持JSON数组.那还在吗 正确吗?我找不到比一年前更新的东西了,令我惊讶的是核心Azure JSON文档存储无法处理数组.

I have a set of JSON documents that each have JSON arrays as a sub property which I need to flatten and iterate over.  After searching through the documentation it seems like the Cosmos dataset type does not support JSON arrays.  Is that still correct?  I can't find anything more recent than a year ago and it surprises me that the core Azure JSON document store can't handle arrays.

在看到Blob存储数据集具有交叉应用嵌套的JSON数组"的能力后, (https://docs.microsoft.com/zh-cn/azure/data-factory/supported-file-formats-and-compression-codecs#jsonformat-example),我将JSON复制到JSON中 文件并将其上传到Blob容器中.按照模式将数组分成扁平的行后,我得到一个数据集,当我按下Azure数据工厂门户网站创作工具中的预览数据"按钮时,它看起来像我想要的样子. 到目前为止一切顺利.

After seeing that the blob storage datasets have the ability to "cross-apply nested JSON array" (https://docs.microsoft.com/en-us/azure/data-factory/supported-file-formats-and-compression-codecs#jsonformat-example), I copied my JSON into a JSON file and uploaded it to a blob container.  After following the pattern to break out an array into flattened rows I end up with a dataset that looks the way I want it to when I hit the Preview data button in the Azure Data Factory portal author tool.  So far so good.

接下来,我创建了一个Lookup活动,以从blob数据集中加载数据,并将其传递给ForEach迭代器以处理扁平化的行.在查找"活动中单击预览"数据,将显示与在数据集编辑器中看到的平展行. 当我尝试在ForEach的复制"活动中使用查找"的输出时,就会出现问题.这些项目以原始JSON文档的格式(而非我期望的拼合格式)从Lookup活动中产生,并且该副本 函数抱怨它无法将输入记录映射到其输入参数.

Next I created a Lookup activity to load the data from the blob dataset and pass it to a ForEach iterator to process the flattened rows.  Clicking on the Preview data in the Lookup activity shows the same flattened rows that I saw in the dataset editor.  The problem comes when I try to use the output from the Lookup in a Copy activity within the ForEach.  The items are coming out of the Lookup activity in the format of the original JSON document and not in the flattened format that I expect, and the copy function complains that it can not map the input record to its input parameters.

是否还有另一个步骤来获取Lookup活动以正确处理JSON数组?我很难找到更多有关此操作方式的示例.

Is there another step to get the Lookup activity to process the JSON arrays properly?  I am having trouble finding more examples of how this is done.

来自blob存储的JSON示例:

Example JSON from blob storage:

{
        "id":"60676CE4-6A14-4620-BD65-6DCAC2C12D5C",
        "用户":{
            "id":"1",
            "电子邮件":"johndoe@abbvie.com",
            " first_name":"John",
            " last_name":" Doe"
        },
        "recommendation_params":[
            {
                键":"c5a2ab1f86959bd6f2e572e9fcfa68ce",
                "params":{
                    " type":"type1",
                    "therapeutic_area":"area1",
                    "territory_ids":[
                        "DB501",
                        "DB502"
                    ],
                    " district_id":"DB5",
                    "regional_id":"DB"
                }
            },
            {
                键":"b26f1a1f0118518634a63a15d518cdf9",
                "params":{
                    " type":"type2",
                    "therapeutic_area":"area2",
                    "territory_ids":[
                        "DB501",
                        "DB502"
                    ],
                    " district_id":"DB5",
                    "regional_id":"DB"
                }
            }
        ]

{
        "id": "60676CE4-6A14-4620-BD65-6DCAC2C12D5C",
        "user": {
            "id": "1",
            "email": "johndoe@abbvie.com",
            "first_name": "John",
            "last_name": "Doe"
        },
        "recommendation_params": [
            {
                "key": "c5a2ab1f86959bd6f2e572e9fcfa68ce",
                "params": {
                    "type": "type1",
                    "therapeutic_area": "area1",
                    "territory_ids": [
                        "DB501",
                        "DB502"
                    ],
                    "district_id": "DB5",
                    "regional_id": "DB"
                }
            },
            {
                "key": "b26f1a1f0118518634a63a15d518cdf9",
                "params": {
                    "type": "type2",
                    "therapeutic_area": "area2",
                    "territory_ids": [
                        "DB501",
                        "DB502"
                    ],
                    "district_id": "DB5",
                    "regional_id": "DB"
                }
            }
        ]

}

预览数据视图:

活动运行的查找输出示例:

Example of the Lookup output from an Activity Run:

交叉应用设置:

谢谢!

亚当

推荐答案

以下是Blob数据集定义:

Here is the blob dataset definition:

{


这篇关于JSON源数据:读取JSON数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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