Please help with json parsing

Hi , I have this json

{ "store_id": 001,
  "products": [
    {"id": 1,"displayName": "name1","prices": [{"isCash": true,"price": 3.69,},{"isCash": false,"price": 3.79,}]},
    {"id": 2,"displayName": "name2","prices":[{"isCash": true,"price": 3.89,},{"isCash": false,"price": 3.99,}]},
    {"id": 3,"displayName": "name3","prices": [{"isCash": true,"price": 3.99,},{"isCash": false,"price": 4.09,}]}
           ]
}

how can I get like this

name1
Cash: 3.69
Not Cash: 3.79
name2
Cash: 3.89
Not Cash: 3.99
name 3
Cash: 3.99
Not Cash: 4.09
I know I can do this like this but I would not want to call the api for every single value

  - platform: rest
    resource: https://api.sample.com/products
    name: products_prices
    json_attributes_path: "$.products[0].prices[0]"
    json_attributes:
      - price
      - isCash
    value_template: 'OK'
    scan_interval: 86400

thanks for help

Use the rest integration (not to be confused with rest sensor). They are very similar but the rest integration only performs 1 pull and you can disperse the information to multiple sensors.

Thank you , got it

1 Like