【问题标题】:Json parse is giving null valuesJson 解析给出空值
【发布时间】:2019-04-05 11:19:19
【问题描述】:

我有一个使用 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"
    }
}

【问题讨论】:

    标签: json azure azure-logic-apps


    【解决方案1】:

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

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

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

    结果:

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

    {
        "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"
                    }
                }
            }
        }
    }
    

    使用 Parse JSON 步骤运行时:

    【讨论】:

    • 嗨 Rick,你可以尝试使用 parse json 操作并发送相同的 scema 来检查我们是否得到输出。请参考我的截图 2,我使用了解析完成后动态内容框中的属性。
    • 这也很好用(看看更新的答案)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-07
    相关资源
    最近更新 更多