JSON解析提供空值

时间:2019-04-05 11:19:20

标签: json azure azure-logic-apps

我有一个逻辑应用程序,该应用程序使用Bind Rest Api获取地址信息。我收到了一个嵌套的json对象。当我尝试解析它时,我在dynamix语法框中得到空值。

下面是我得到的json对象,但是当我在解析后将它们用作属性时,它们被标记为null:

{
    "address": {
            "addressLine": "1-11-252, Begumpet Road",
            "adminDistrict": "TS",
            "adminDistrict2": "Hyderabad",
            "countryRegion": "India",
            "formattedAddress": "1-11-252, Begumpet Road, Hyderabad, TS 500016",
            "intersection": {
                "baseStreet": "Begumpet Road",
                "secondaryStreet1": "Chikoti Garden No-4 Road",
                "intersectionType": "Near",
                "displayName": "Begumpet Road and Chikoti Garden No-4 Road"
            },
            "locality": "Hyderabad",
            "neighborhood": "Begumpet",
            "postalCode": "500016",
            "countryRegionIso2": "IN"
    }
}

Image 1

Image 2

Image 3

1 个答案:

答案 0 :(得分:0)

根据您的信息,这是我所做的:

  1. 在Azure门户中创建逻辑应用
  2. 选择了“收到HTTP请求时”触发器
  3. 单击“使用示例有效负载来生成模式”链接并粘贴示例数据(请参见下方!
  4. 添加了“响应”操作
  5. 将响应的正文定义为:
{
    "address": baseStreet
}

baseStreet是对baseStreet动态内容的引用。

结果:
The resulting Logic App

重要!
请注意,请求正文JSON模式与有效负载不同:

{
    "type": "object",
    "properties": {
        "address": {
            "type": "object",
            "properties": {
                "addressLine": {
                    "type": "string"
                },
                "adminDistrict": {
                    "type": "string"
                },
                "adminDistrict2": {
                    "type": "string"
                },
                "countryRegion": {
                    "type": "string"
                },
                "formattedAddress": {
                    "type": "string"
                },
                "intersection": {
                    "type": "object",
                    "properties": {
                        "baseStreet": {
                            "type": "string"
                        },
                        "secondaryStreet1": {
                            "type": "string"
                        },
                        "intersectionType": {
                            "type": "string"
                        },
                        "displayName": {
                            "type": "string"
                        }
                    }
                },
                "locality": {
                    "type": "string"
                },
                "neighborhood": {
                    "type": "string"
                },
                "postalCode": {
                    "type": "string"
                },
                "countryRegionIso2": {
                    "type": "string"
                }
            }
        }
    }
}

使用“解析JSON”步骤运行时:
Parse JSON