Getting a value from json for a gauge

I'm new to this, so much to learn with Home Assistant, Tasmota, Grafana and now Node Red.

I'm trying to construct a Node Red Dashboard to display and control my Owl Intuition Electricity monitor and Central Heating system.

Stuck on how to get the "current power" value out of the json payload to feed into a gague.

The message comes in OK via UDP Multicast node which then goes through a switch node to separate the flows for the 3 different message types. Each then goes through a XML node which puts it into a jsons format (I think).
Originally I had that output going to the gauge with the path to the element I wanted copied from that element in the debug window. Although the gauge showed the right level the text was the whole thing so I read somewhere to get just the value I wanted by a function node.
So I put the path into the function but I get the error that it is returning a string.
What am I doing wrong?
My line in the function is:

return msg.payload.electricity.chan[0].curr[0]._;

The payload it's trying to read is:

{"electricity":{"$":{"id":"443719002FAD"},"timestamp":["1606673600"],"signal":[{"$":{"rssi":"-53","lqi":"12"}}],"battery":[{"$":{"level":"100%"}}],"chan":[{"$":{"id":"0"},"curr":[{"_":"1384.00","$":{"units":"w"}}],"day":[{"_":"19130.05","$":{"units":"wh"}}]},{"$":{"id":"1"},"curr":[{"_":"0.00","$":{"units":"w"}}],"day":[{"_":"0.00","$":{"units":"wh"}}]},{"$":{"id":"2"},"curr":[{"_":"0.00","$":{"units":"w"}}],"day":[{"_":"0.00","$":{"units":"wh"}}]}]}}

Welcome to the forum.

Have a look here:

A function needs to return an object as the debug node by default wants to read from msg.payload, a string was given, hence the error.

return {payload:msg.payload.electricity.chan[0].curr[0]._};

Personally i find it cleaner with a change node in combination with jsonata (can directly parse it as a number as well), or just extract it like "normal"

Brilliant. The first method worked on the example i gave, and on another feeding a graph. Thanks. I will try the second method too as i have many more values to extract.
So much to learn, and i like to learn by setting myself a project; it would be a lot harder without people like you showing us newbies the way.

By the way, that isn't JSON, it is a javascript object. JSON is always a string, that can be converted to a js object by feeding it through a JSON node (or vice versa).