2

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

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

我写了一个与下面相同的事件定义,

event E {


 dictionary<string,dictionary<dictionary<string,string>,dictionary<string,sequence<sequence<sequence<sequence<float > > > > > > > geometry;

dictionary<string,string> properties;
    }

但是在运行时它给出了错误:Expecting map but getting a list。

请帮忙。

4

1 回答 1

2

您将几何视为字符串键和字典值的字典。这不是真的,因为第一个条目是一个字符串:字符串对。您会更适合声明事件类型,如下所示:

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

event E {
    Geometry geometry;
    dictionary<string,string> properties;
}
于 2019-05-15T13:14:30.837 回答