Problems with extracting JSON value in OH3

Dear all,

i have OH3 running, HTTP binduing and JSONPATH transform installed.

I have this URL:
https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=&objectIds=76&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=cases_per_100k%2Ccases7_per_100k&returnGeometry=false&returnCentroid=false&featureEncoding=esriDefault&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=4326&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=false&returnDistinctValues=false&cacheHint=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pjson&token=

It returns:

{
  "objectIdFieldName" : "OBJECTID", 
  "uniqueIdField" : 
  {
    "name" : "OBJECTID", 
    "isSystemMaintained" : true
  }, 
  "globalIdFieldName" : "", 
  "geometryType" : "esriGeometryPolygon", 
  "spatialReference" : {
    "wkid" : 4326, 
    "latestWkid" : 4326
  }, 
  "fields" : [
    {
      "name" : "cases_per_100k", 
      "type" : "esriFieldTypeDouble", 
      "alias" : "Fälle/100.000 EW", 
      "sqlType" : "sqlTypeOther", 
      "domain" : null, 
      "defaultValue" : null
    }, 
    {
      "name" : "cases7_per_100k", 
      "type" : "esriFieldTypeDouble", 
      "alias" : "Fälle letzte 7 Tage/100.000 EW", 
      "sqlType" : "sqlTypeOther", 
      "domain" : null, 
      "defaultValue" : null
    }
  ], 
  "features" : [
    {
      "attributes" : {
        "cases_per_100k" : 2119.85035308702, 
        "cases7_per_100k" : 113.120669426427
      }
    }
  ]
}

I would like to extract the value in ‘cases_per_100k’.

I created this thing:

This is the thing code I added:

UID: http:url:66fe49bee5
label: Corona Mettmann
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=&objectIds=76&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=cases_per_100k%2Ccases7_per_100k&returnGeometry=false&returnCentroid=false&featureEncoding=esriDefault&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=4326&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=false&returnDistinctValues=false&cacheHint=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pjson&token=
  refresh: 30
  commandMethod: GET
  contentType: application/json
  timeout: 3000
  bufferSize: 2048
channels:
  - id: cases7_per_100k
    channelTypeUID: http:number
    label: Inzident pro 100k
    description: null
    configuration:
      stateTransformation: JSONPATH:$.features.attributes.cases7_per_100k

But when I check, the valoue remains empty:

But it shoudl be
image

Any help appreciated!

Can you copy/paste the JSON into your post, rather than a screenshot? Allows us to quickly test…

I added the JSON, which is returned.

Does

JSONPATH:$.features..cases7_per_100k

work? Or

JSONPATH:$.features.*.attributes.cases7_per_100k

Or

JSONPATH:$.features[*].attributes.cases7_per_100k

Unfortunately no change in the behaviour. The value is always NULL.

Interesting - all three of the examples work for me in openHAB using the JSON you posted in the OP, though I’ve tested them through the MQTT Binding, and therefore MQTT Generic Things, rather than HTTP URL Things. I don’t think that should make a difference though…

Are you aware that the screenshot of the Item you’re showing us is of a Group Item? What Item do you actually have linked to the cases7_per_100k Channel?

This is the config of the channel:

and the linked item:

In the logs, there is a waring, which is related to this topic:

2021-01-16 22:57:45.548 [WARN ] [ttp.internal.http.RefreshingUrlCache] - Creating request for 'https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=&objectIds=76&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=cases_per_100k%2Ccases7_per_100k&returnGeometry=false&returnCentroid=false&featureEncoding=esriDefault&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=4326&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=false&returnDistinctValues=false&cacheHint=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pjson&token=' failed: c != java.util.Date

Yes, so as I thought: this isn’t about the JSONPATH at all - something’s going wrong requesting the data?

Unfortunately I can’t help further as I have no idea what the error means! @J-N-K might be able to help (sorry for the ping), but please copy/paste the WARN message info your post, rather than a screenshot…

The problem is %2c which the binding tries to use as formatter input. Try replacing that with a ,.

thanks to @hafniumzinc and @J-N-K . Not it works. I’ll adopt a bit and share afterwards here.

have a great day!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.