我正在从 api 访问天气数据,并想使用 Apache nifi 来获取第一个 api 返回的 json 数组中所有城市的天气数据?
基本上我通过 2 个 API 访问数据:
这个 api 返回一个 JSON 数组,其中包含 JSON 数组元素中美国所有城市的列表:
{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"conditions": 1
}
, "results": [
{
"name": "Keyhole",
"city": "Keyhole",
"state": "WY",
"country": "US",
"country_iso3166":"US",
"country_name":"USA",
"zmw": "82721.7.99999",
"l": "/q/zmw:82721.7.99999"
}
,
{
"name": "Cuchara Valley Airport At La Veta",
"city": "Cuchara Valley Airport At La Veta",
"state": "CO",
"country": "US",
"country_iso3166":"US",
"country_name":"USA",
"zmw": "81055.6.99999",
"l": "/q/zmw:81055.6.99999"
}
,
现在我想遍历这个数组并使用要在另一个 API 中使用的州和城市信息,如下所示:
{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"conditions": 1
}
}
, "current_observation": {
"image": {
"url":"http://icons.wxug.com/graphics/wu2/logo_130x80.png",
"title":"Weather Underground",
"link":"http://www.wunderground.com"
},
"display_location": {
"full":"San Francisco, CA",
"city":"San Francisco",
"state":"CA",
"state_name":"California",
"country":"US",
"country_iso3166":"US",
"zip":"94101",
"magic":"1",
"wmo":"99999",
"latitude":"37.77500916",
"longitude":"-122.41825867",
"elevation":"47.00000000"
},
"observation_location": {
"full":"SOMA - Near Van Ness, San Francisco, California",
"city":"SOMA - Near Van Ness, San Francisco",
"state":"California",
"country":"US",
"country_iso3166":"US",
"latitude":"37.773285",
"longitude":"-122.417725",
"elevation":"49 ft"
},...
所以基本上我必须为我从第一个 API 获得的所有州和城市组合循环运行第二个 api。
到目前为止,我所做的基本 NiFi 流程与这个问题一样,但它不起作用。有人可以帮我弄清楚我在这里做错了什么吗?