简体   繁体   English

如何在Node-RED中拆分JSON字符串后提取值

[英]How to extract a value after splitting a JSON String in Node-RED

I am injecting a String into my flow, then making it into a JSON String with the JSON node and splitting it with the split node. 我正在向我的流中注入一个String,然后将其转换为带有JSON节点的JSON字符串,并将其与拆分节点分开。 I get 5 messages out of this split node because there are 5 values with 5 properties. 我从这个拆分节点中获取了5条消息,因为有5个值包含5个属性。 What I need is to extract only one of the values, to then use it in a function node. 我需要的是只提取其中一个值,然后在函数节点中使用它。 How can I do this? 我怎样才能做到这一点?

在此输入图像描述

This is a picture of one of the 5 outputs. 这是5个输出中的一个的图片。 What I want is to ONLY use the value (137) in a function node that should come after the split node. 我想要的是只使用应该在拆分节点之后的函数节点中的值(137)。 Thanks in advance. 提前致谢。

You do nothing. 你什么都不做。

You just access the value as msg.payload in the function node. 您只需在函数节点中以msg.payload访问该值。

msg.payload.energy_wh 

这将访问函数节点中的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM