There is no way to get the keys out of the json using the version of jsonpath that is used by OH. It looks like you may know what the possible keys may be though, so you can make your own list to iterate over…
val KEYS = newArrayList("mode", "acPowerIn", "acPowerInMin", "acPowerInMax", "acPowerOut", "thisDoesNotExistInTheCurrentData")
val TEST_DATA = '{"mode": "auto", "acPowerIn": 3000, "acPowerInMin": 200, "acPowerInMax": 3680, "acPowerOut": 3000}'
for (key: KEYS) {
val RESULT = transform("JSONPATH", "$." + key, TEST_DATA)
if (RESULT != TEST_DATA) {
logWarn("Test", "{}: {}", key, RESULT)
}
}
Using a real scripting language, like Jython, you can easily convert to json and iterate through the keys. The logging will be simpler in a rule, but…
import json
from core.log import logging, LOG_PREFIX#, log_traceback
LOG = logging.getLogger("{}.TEST_3".format(LOG_PREFIX))
TEST = '{"mode": "auto", "acPowerIn": 3000, "acPowerInMin": 200, "acPowerInMax": 3680, "acPowerOut": 3000}'
CONVERTED_TO_JSON = json.loads(TEST)
for key, value in CONVERTED_TO_JSON.iteritems():
LOG.warn("{}: {}".format(key, value))