方法在控制台中返回正确的数据,但在restful api call

时间:2016-03-10 19:05:52

标签: dart rpc

我有一个设置的服务器,当我设置构造函数时,我传入了一个地图。

当服务器加载时,我调用一个名为getDaily的函数,它返回应该看的数据,但仅在命令控制台中。

在json的http请求中,它似乎只做一个浅拷贝,返回

{
 "summary": {},
 "icon": {},
 "data": {}
}

该功能如下所示:

@ApiMethod(method:'GET', path: 'daily')
Map<String, Object> getDaily(){
  return myWeather.daily;
}

为什么不返回数据?这是它应该返回的内容。

{
  "summary":"Light rain throughout the week, with temperatures rising to 76°F on Wednesday.",
  "icon":"rain",
  "data":[{"time":1457586000,"summary":"Rain in the morning and afternoon.","icon":"rain","sunriseTime":1457610016,"sunsetTime":1457652167,"moonPhase":0.06,"precipIntensity":0.0263,"precipIntensityMax":0.1133,"precipIntensityMaxTime":1457654400,"precipProbability":0.81,"precipType":"rain","temperatureMin":56.96,"temperatureMinTime":1457611200,"temperatureMax":65.1,"temperatureMaxTime":1457632800,"apparentTemperatureMin":56.96,"apparentTemperatureMinTime":1457611200,"apparentTemperatureMax":65.1,"apparentTemperatureMaxTime":1457632800,"dewPoint":53.19,"humidity":0.78,"windSpeed":4.28,"windBearing":224,"visibility":7.84,"cloudCover":0.9,"pressure":1016.53,"ozone":281.24},{"time":1457672400,"summary":"Mostly cloudy throughout the day.","icon":"partly-cloudy-day","sunriseTime":1457696318,"sunsetTime":1457738631,"moonPhase":0.1,"precipIntensity":0.0028,"precipIntensityMax":0.0257,"precipIntensityMaxTime":1457672400,"precipProbability":0.64,"precipType":"rain","temperatureMin":43.34,"temperatureMinTime":1457708400,"temperatureMax":53.67,"temperatureMaxTime":1457672400,"apparentTemperatureMin":40.42,"apparentTemperatureMinTime":1457701200,"apparentTemperatureMax":53.67,"apparentTemperatureMaxTime":1457672400,"dewPoint":42.5,"humidity":0.82,"windSpeed":4.49,"windBearing":325,"visibility":9.38,"cloudCover":0.76,"pressure":1026.31,"ozone":292.63},{"time":1457758800,"summary":"Mostly cloudy throughout the day.","icon":"partly-cloudy-day","sunriseTime":1457782621,"sunsetTime":1457825095,"moonPhase":0.14,"precipIntensity":0.001,"precipIntensityMax":0.0028,"precipIntensityMaxTime":1457820000,"precipProbability":0.09,"precipType":"rain","temperatureMin":36.28,"temperatureMinTime":1457780400,"temperatureMax":63.46,"temperatureMaxTime":1457809200,"apparentTemperatureMin":35.53,"apparentTemperatureMinTime":1457773200,"apparentTemperatureMax":63.46,"apparentTemperatureMaxTime":1457809200,"dewPoint":44.99,"humidity":0.84,"windSpeed":1.72,"windBearing":128,"visibility":10,"cloudCover":0.73,"pressure":1022.99,"ozone":293.44},{"time":1457845200,"summary":"Light rain in the morning and afternoon.","icon":"rain","sunriseTime":1457868923,"sunsetTime":1457911559,"moonPhase":0.17,"precipIntensity":0.0053,"precipIntensityMax":0.0109,"precipIntensityMaxTime":1457902800,"precipProbability":0.52,"precipType":"rain","temperatureMin":52.96,"temperatureMinTime":1457845200,"temperatureMax":71.49,"temperatureMaxTime":1457902800,"apparentTemperatureMin":52.96,"apparentTemperatureMinTime":1457845200,"apparentTemperatureMax":71.49,"apparentTemperatureMaxTime":1457902800,"dewPoint":56.83,"humidity":0.87,"windSpeed":2.97,"windBearing":134,"visibility":9.91,"cloudCover":0.92,"pressure":1013.74,"ozone":299.29},{"time":1457928000,"summary":"Drizzle in the evening and overnight.","icon":"rain","sunriseTime":1457955225,"sunsetTime":1457998022,"moonPhase":0.21,"precipIntensity":0.0052,"precipIntensityMax":0.0103,"precipIntensityMaxTime":1457931600,"precipProbability":0.51,"precipType":"rain","temperatureMin":59.04,"temperatureMinTime":1457949600,"temperatureMax":73.52,"temperatureMaxTime":1457989200,"apparentTemperatureMin":59.04,"apparentTemperatureMinTime":1457949600,"apparentTemperatureMax":73.52,"apparentTemperatureMaxTime":1457989200,"dewPoint":60.17,"humidity":0.9,"windSpeed":4.85,"windBearing":200,"cloudCover":0.7,"pressure":1009.02,"ozone":314.24},{"time":1458014400,"summary":"Mostly cloudy in the morning.","icon":"partly-cloudy-night","sunriseTime":1458041526,"sunsetTime":1458084485,"moonPhase":0.25,"precipIntensity":0.0035,"precipIntensityMax":0.0082,"precipIntensityMaxTime":1458021600,"precipProbability":0.42,"precipType":"rain","temperatureMin":55.92,"temperatureMinTime":1458039600,"temperatureMax":73.84,"temperatureMaxTime":1458072000,"apparentTemperatureMin":55.92,"apparentTemperatureMinTime":1458039600,"apparentTemperatureMax":73.84,"apparentTemperatureMaxTime":1458072000,"dewPoint":58.97,"humidity":0.88,"windSpeed":4.09,"windBearing":237,"cloudCover":0.38,"pressure":1010.03,"ozone":316.31},{"time":1458100800,"summary":"Rain starting in the afternoon.","icon":"rain","sunriseTime":1458127827,"sunsetTime":1458170948,"moonPhase":0.28,"precipIntensity":0.0161,"precipIntensityMax":0.068,"precipIntensityMaxTime":1458176400,"precipProbability":0.76,"precipType":"rain","temperatureMin":54.45,"temperatureMinTime":1458126000,"temperatureMax":75.67,"temperatureMaxTime":1458158400,"apparentTemperatureMin":54.45,"apparentTemperatureMinTime":1458126000,"apparentTemperatureMax":75.67,"apparentTemperatureMaxTime":1458158400,"dewPoint":59.84,"humidity":0.87,"windSpeed":4.86,"windBearing":203,"cloudCover":0.41,"pressure":1012.93,"ozone":305.69},{"time":1458187200,"summary":"Light rain starting in the afternoon.","icon":"rain","sunriseTime":1458214128,"sunsetTime":1458257411,"moonPhase":0.32,"precipIntensity":0.0165,"precipIntensityMax":0.0516,"precipIntensityMaxTime":1458187200,"precipProbability":0.73,"precipType":"rain","temperatureMin":48.85,"temperatureMinTime":1458270000,"temperatureMax":71.11,"temperatureMaxTime":1458237600,"apparentTemperatureMin":43.98,"apparentTemperatureMinTime":1458262800,"apparentTemperatureMax":71.11,"apparentTemperatureMaxTime":1458237600,"dewPoint":55.91,"humidity":0.86,"windSpeed":4.71,"windBearing":213,"cloudCover":0.92,"pressure":1009.81,"ozone":310.25}]
}

两次都会调用完全相同的函数。

编辑在github上查找RPC时https://github.com/dart-lang/rpc/blob/master/test/src/parser/api_common_method_test.dart它实际上没有提到做Map<String, Object>所以我认为这可能是RPC的无效返回值?< / p>

0 个答案:

没有答案