Microsoft Azure IoT Hub:将消息从base64格式解码到消息路由中的8-UTF查询
我有一个将传感器数据发送到Iot-Hub的设备。我从设备中获得的消息是用Base64格式编码的。我无法在设备的设置中更改它。因此,当我打开JSON数据时,“主体”值会被编码(无法读取),并且必须转换为UTF-8格式。我想知道是否可以在Iot Hub中的“消息路由查询”中编写代码,以便Microsoft Azure自动以格式化UTF-8转换接收的JSON数据以查看信号的值?
预先感谢
BR 马苏德
I have a device which sends sensor data to an IoT-hub. The messages that I get from the device are with base64 format encoded. I cannot change it in my device's settings. Thus, when I open the JSON data, the "body" values are encoded (cannot be read) and must be converted to the UTF-8 format. I would like to know whether it is possible to write a code in "message route query" in IoT Hub so that Microsoft azure automatically converts the received JSON data in format UTF-8 to see the values of the signals?
Thanks in advance
Br
Masoud
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将消息发送为 utf-8 编码 JSON 正在对您的消息对象设置两个步骤。将以下代码添加到我的应用程序将解决问题。您可以参考此 github link 。
参考:
https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub/iot-hub-devguide-messages-d2c#routing-endpoints
/learn.microsoft.com/en-us/dotnet/api/system.convert.frombase64string?view=NetFramework-4.8“ rel =“ nofollow noreferrer”> https://learlen.microsoft.com/microsoft.com/en-en-us/dotnet/ api/system.convert.frombase64string?view = netFramework-4.8
Sending the message as UTF-8 encoded JSON is setting two steps on your message object. Adding the following code to my application will solve the problem. You can refer this GitHub link .
Reference:
https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-d2c#routing-endpoints
https://learn.microsoft.com/en-us/dotnet/api/system.convert.frombase64string?view=netframework-4.8