Apama HTTPClient适配器中的JSON响应解析

时间:2019-05-15 11:10:47

标签: apama

我想使用apama中的HTTPClient适配器解析来自HTTP REST调用的JSON响应。响应字符串如下,

Browse to MSI

我为下面的内容写了一个事件定义,

{
    "geometry": {
                "type": "MultiPolygon",
                "cordinates": [
                                [   
                                    [
                                        [
                                            -2.420261362208627,
                                            51.29662513520916
                                        ],
                                        [
                                            -2.42211658046158,
                                            51.28747916639892
                                        ],
                                        [
                                            -2.439047101373828,
                                            51.28519049850415
                                        ],
                                        [
                                            -2.453288677334455,
                                            51.273848703615954
                                        ]
                                    ]
                                ]   
                            ]
            },          
      "properties": {
                "name": "Bath and NE Somerset",
                "public_name": "Bath and North East Somerset",
                "region": "South West",
                "public_region": "South West"
            }
}

但是在运行时,它给出了错误:需要地图但得到列表。

请帮助。

1 个答案:

答案 0 :(得分:2)

您正在将几何视为字符串键和字典值的字典。这是不正确的,因为第一个条目是string:string对。您更适合声明事件类型,例如:

event Geometry {
    string type;
    sequence<sequence<sequence<sequence<float> > > > coordinates;
}

event E {
    Geometry geometry;
    dictionary<string,string> properties;
}