How to use transform with JSONPATH?

Tags: #<Tag:0x00007f616d00a2f0> #<Tag:0x00007f616d00a0c0>

I’m trying to extract a value from this JSON using ‘transform’ in a rule.

  "request": {
    "station": "1448",
    "date_from": "2020-01-18",
    "date_to": "2020-01-18",
    "time_from": "19:00:00",
    "time_to": "19:00:00",
    "lang": "de",
    "index": "code",
    "datetime_from": "2020-01-18 18:00:00",
    "datetime_to": "2020-01-18 18:00:00"
  "data": {
    "1448": {
      "2020-01-18 18:00:00": [
        "2020-01-18 19:00:00",
  "indices": {
    "data": {
      "station id": {
        "date start (CET)": [
          "date end (CET)"
        "date start": {
          "1": "total index",
          "2": "data incomplete",
          "3": [
            "component id",
  "count": 1

The specific value that I’m looking for is “45”. When I analyze the JSON using “jsonpath online evaluator”, the following syntax

$.data.1448.2020-01-18 18:00:00.3.1

delivers the right result:


Using this same expression in a rule

val newValue = transform("JSONPATH", "$.data.1448.2020-01-18 18:00:00.3.1", NOX_JSON.state.toString)

with NOX_JSON being the JSON expression above, I get “NULL” as a result.
What is wrong with my way of using “transform”?

Or null ?
These are not the same - NULL is the state of an Item that hasn’t been updated yet.
Check in events.log that Item NOX_JSON has received some value at some time.

The item gets updated now but with the entire JSON - not with the filter that I’m expecting from the transform expression. Are there any special format requirements for the JSONPATH syntax in a rule compared to the online evaluator?

I would guess a Jython rule would work. @rlkoshak could advise further.

Yes, I don’t know what exactly. openHAB JSONPATH transformation service is not JSONPATH. For example, it always returns strings, you cannot return an array etc.

The “date”=looking key looks suspect to me - spaces and colons in it.