JSON number formating

Hi there,

I know this is a really silly question but I am struggling to find the correct format for dividing a number by 10. The temperature value is delivered as 460 but I would like it to be viewed as 46.0 which is the correct value.

I am extracting the value from a JSON payload using the ‘Attribute links’ functionality as per the below extract.

{
“ref”: {
“id”: “5GKKFffN3EHo6XyyNQ4vbT”,
“name”: “ModemTemp”
},
“filters”: [
{
“type”: “jsonPath”,
“path”: “$.GatewayGSM.modemtemp”,
“returnFirst”: true,
“returnLast”: false
}
]
},

Any help or pointing to an example would be much appreciated.

Thanks,

Alan

Based on more reading I now believe the correct solution is to use regex and then stitch together again in JSON. Unfortunately I seem unable to get my regex to save, am I correct in using the “pattern” key for the regex?

Hi!

First of all, welcome to the forum! :partying_face:

The regex in ‘Attribute links’ should look something like this;

{
    "type": "regex",
    "pattern": ".*(\\d)$",
    "matchGroup": 1
}

If interested, you can take a look at the source code for the RegexValueFilter here.
As of now, it supports the fields pattern, matchGroup, and matchIndex.

Hi Martin,

Thank you for the welcome, I have been reading many posts and found the forum a good resource.

Thank you for providing a sample format, I will have a play with this and see how far it can take me.

Thanks :slight_smile:

1 Like