当我得到温度值时,我觉得格式有问题。当我调用这个参数时,我总是用"d0“f.e.得到它。"-0,39d0“。我怎么才能修复它?我的代码:
<category>
<pattern>PADANIE</pattern>
<template>
<think>
<set name="weather_t">
<callapi>
<url>http://api.openweathermap.org/data/2.5/weather</url>
<method>GET</method>
<query name="appid"><secret name="openweathermap_secret_appid"/></query>
<query name="q">zyrardow</query>
<query name="units">metric</query>
<query name="lang">pl</query>
<filter type="jsonpath">$.main.temp</filter>
</callapi>
</set>
</think>
<get name="weather_t"/>.
</template>
</category>如果我使用jsonpath而不是filter,结果是相同的。
<category>
<pattern>PADANIE</pattern>
<template>
<think>
<set var="weather_t">
<callapi>
<url>http://api.openweathermap.org/data/2.5/weather</url>
<method>GET</method>
<query name="appid"><secret name="openweathermap_secret_appid"/></query>
<query name="q">zyrardow</query>
<query name="units">metric</query>
<query name="lang">pl</query>
</callapi>
</set>
</think>
<jsonpath><path>$.main.temp</path><get var="weather_t"/></jsonpath>
</template>
</category>发布于 2021-01-13 22:28:06
这就是openweathermap API显示结果的方式。摆脱d0部分的最简单方法是对输出进行反规范化。
将此代码添加到您的非正规替换文件中:
["0d0", "0"],
["1d0", "1"],
["2d0", "2"],
["3d0", "3"],
["4d0", "4"],
["5d0", "5"],
["6d0", "6"],
["7d0", "7"],
["8d0", "8"],
["9d0", "9"],在您的第一个类别中,替换:
<get name="weather_t"/>使用
<denormalize><get name="weather_t"/></denormalize>它现在应该可以工作了

https://stackoverflow.com/questions/65679547
复制相似问题