This is json, and you should be able to use the JSONPATH transformation service with it. If it’s not working, check for quotes.
This should work if the JSONPATH addon is installed…
var transformedTest = transform("JSONPATH", "$.data", test.state.toString)
This is another really good use for Jython too, since you’d just bring the data in as a dictionary. I don’t know what PiJuice is, but you may be able to use the package directly in a rule too.