【问题标题】:JSON parsing to table through KNIMEJSON通过KNIME解析到表
【发布时间】:2019-08-20 15:20:48
【问题描述】:

我正在尝试通过 KNIME 解析 JSON 文件,现在在输出中我们得到 4 行是正确的,但在这 4 行中(对应于输入 JSON 中 PsnameId 参数的数量)。

现在我们需要为Flgs.cd(Flgs.cd1,Flgscd2....Flgs.cd10)Flgs.des(Flgs.des1,Flgs.des2....Flgs.des10) 增加10 个新列,它们应该从参数Flgs.cdFlgs.des 中获取数据。

Row 1 应该在 Flgs.cd1 中有数据,如 A1Flgs.Cd2 作为 A2Flgs.cd3 作为 null...Flgs.cd10 作为 null(因为下面有两个元素Flgs 参数)和Flgs.des1 作为第一个系统,Flgs.des2 作为第二个系统...Flgs.des10 作为null

Row 2 应该在 Flgs.cd1 中有数据,如 B1Flgs.cd2 作为 B2Flgs.cd3 作为 B3...Flgs.cd10 作为 null(因为下面有三个元素Flgs参数)和Flgs.des1作为第一系统,Flgs.des2作为第二系统,Flgs.des3作为第三系统...Flgs.des10作为null

Row 3 应该在Flgs.cd1 中有数据,如nullFlgs.cd2nullFlgs.cd3 作为null...Flgs.cd10 作为null(因为下面没有元素Flgs 参数)和Flgs.des1 作为nullFlgs.des2 作为null...Flgs.des10 作为null

Row 4 应该在 Flgs.cd1 中有数据,如 nullFlgs.cd2 作为 nullFlgs.cd3 作为 null...Flgs.cd10 作为 null(因为下面没有元素Flgs 参数)和Flgs.des1 作为nullFlgs.des2 作为null...Flgs.des10 作为null

我已尝试将 Ungroup 用于 Flgs 参数作为节点 15,但它创建的新行等于每个 PsnameId 下存在的 Flgs 元素的数量,这不是预期的输出。如果可以的话,请告诉我

JSON 输入:

{
"mod": "8976",
"machine": {
    "Comments": [],
    "machineis": false,
    "Person": {
        "Address": null,
        "Gender": "Female",
        "LastName": "juhi",
        "Location": null,
        "MiddleName": null
    },
    "Specials": [{
        "Comments": [],
        "DDateTime": "2018-11-14T09:40:37",
        "Contain": [{
            "Comments": null,
            "CID": "256521",
            "Instance": [{
                "ADateTime": null,
                "ObsertsRIDs": ["11", "12"],
                "RID": "11",
                "Type": null
            }, {
                "ADateTime": null,
                "ObsertsRIDs": ["13", "14"],
                "RID": "12",
                "Type": null
            }],
            "Obserts": [{
                "PsnameId": "123-7",
                "PsName": "gdsa DF",
                "RstID": "11",
                "Result": {
                    "Comments": [],
                    "CompletedDateTime": null,
                    "RsltID": "11"
                },
                "Flgs": [
                    {
                        "Cd": "A1",
                        "Des": "first system",
                        "Type": "null"
                    },
                    {
                        "Cd": "A2",
                        "Des": "second system",
                        "Type": "null"
                    }
                ],
                "Type": null,
                "Version": 0
            }, {
                "PsnameId": "897-1",
                "PsName": "sads RT",
                "RstID": "12",
                "Result": {
                    "Comments": [],
                    "CompletedDateTime": null,
                    "RsltID": "12"
                },
                "Flgs": [
                    {
                        "Cd": "B1",
                        "Des": "first system",
                        "Type": "null"
                    },
                    {
                        "Cd": "B2",
                        "Des": "second system",
                        "Type": "null"
                    },
                    {
                        "Cd": "B3",
                        "Des": "third system",
                        "Type": "null"
                    }
                ],
                "Type": null,
                "Version": 0
            },  {
                "PsnameId": "897-1",
                "PsName": "sads RT",
                "RstID": "13",
                "Result": {
                    "Comments": [],
                    "CompletedDateTime": null,
                    "RsltID": "13"
                },
                "Flgs": [],
                "Type": null,
                "Version": 0
            },{
                "PsnameId": "891-1",
                "PsName": "rgst LT",
                "RstID": "14",
                "Result": {
                    "Comments": [],
                    "CompletedDateTime": null,
                    "RsltID": "14"
                },
                "Flgs": [],
                "Type": null,
                "Version": 0
            }],
            "CAct": null,
            "Type": null,
            "Version": 0
        }],
        "Type": null,
        "Version": 0
    }],
    "Cals": null,
    "Pals": null,
    "Type": null,
    "Version": 0
}
}

输出表格图片:

【问题讨论】:

    标签: json knime


    【解决方案1】:

    如果我理解正确,您正在寻找UngroupPivoting。透视需要一些配置,但它应该通过一些实验来工作,不要害怕Ungroup 结果行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多