Solved: Question on JSONPATH

Hi team,

I’m on OH3 and I’ struggling to extract certain values from here: https://api.corona-zahlen.org/states/

Therefore I configured this thing based on the HTTP binding:

UID: http:url:a6efe98704
label: Covid Bundesländer
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: https://api.corona-zahlen.org/states/
  delay: 0
  stateMethod: GET
  refresh: 30
  commandMethod: GET
  contentType: application/json
  timeout: 3000
  bufferSize: 2048
channels:
  - id: weekIncidence_NRW
    channelTypeUID: http:number
    label: Inzident pro 100k NI
    description: null
    configuration:
      stateTransformation: JSONPATH:$.data[NW].weekIncidence
  - id: weekIncidence_NI
    channelTypeUID: http:number
    label: Inzident pro 100k NRW
    description: null
    configuration:
      stateTransformation: JSONPATH:$.data[NI].weekIncidence
  - id: population_NRW
    channelTypeUID: http:number
    label: Einwohner NRW
    description: null
    configuration:
      stateTransformation: JSONPATH:$.data[NW].population
  - id: population_NI
    channelTypeUID: http:number
    label: Einwohner NI
    description: null
    configuration:
      stateTransformation: JSONPATH:$.data[NI].population
  - id: last_update
    channelTypeUID: http:datetime
    label: last updates
    description: null
    configuration:
      stateTransformation: JSONPATH:$.meta.lastUpdate

In the logs I get this warning:

2021-03-21 07:50:21.104 [WARN ] [.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern='$.data[NI].weekIncidence', serviceName='JSONPATH'} failed: An error occurred while transforming JSON expression.

2021-03-21 07:50:21.110 [WARN ] [.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern='$.data[NW].weekIncidence', serviceName='JSONPATH'} failed: An error occurred while transforming JSON expression.

2021-03-21 07:50:21.113 [WARN ] [.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern='$.data[NI].population', serviceName='JSONPATH'} failed: An error occurred while transforming JSON expression.

2021-03-21 07:50:21.116 [WARN ] [.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern='$.data[NW].population', serviceName='JSONPATH'} failed: An error occurred while transforming JSON expression.


and the item receives just NULL:

I validated the JSONPATH ($.data[NI].weekIncidence) using the online validator (http://jsonpath.com/), and it seems to be correct:

I’m wondering, what’s wrong here.

Thanks again for support!

Matthias

As per Docks its Jayway

Get your info from GitHub - json-path/JsonPath: Java JsonPath implementation

Use this evaluator https://jsonpath.herokuapp.com/

Change

to JSONPATH$.data.NW.weekIncidence