How to reference context variable with underscore

Is there a different syntax for using the expression editor to pull in json values that contain an underscore?

When I attempt to round any field that include an underscore “_” in them, the expression editor returns an ‘expression evaluation error’ – it turns out that I can’t use the expression editor to pull in the value at all. (I can pull in the value using the context variable).

This happens on any of the fields that contain an underscore: ‘feels_like’, ‘dew_point’, etc. (pulling in from the OpenWeather API).

The word after the underscore gets truncated.



I suspect it’s probably a bug in the variable parser. The inline expression editor uses the same parser and normally would have flagged it, but the expression editor uses a different validator.

In the meantime, since you’re using a full expression, you could alias the parent property which doesn’t have an underscore and then reference the property under that:

current = $

Perfect, works great – thanks!

Is there any way to use a variable to construct a context variable, as in[$indexVariable].level

You can use the same concept of using an alias. Expressions themselves must execute synchronously in a sandboxed environment, so the variable references are actually swapped out before the expression evaluation runs and thus can’t be nested. But once things are running inside the expression, you can use variables in field accessors.

data = $
1 Like

Ah, I was soooooooooo close. :joy:


1 Like

We pushed an update today to handle properties with underscores in their name, so you should be able to use the property from the context variable directly if you prefer now.

1 Like