Hello, I am having trouble creating a Rest Sensor, which value is the lenght of an JSON Array.
I am retreiving the following JSON file, by API:
{
"countries": [{
"store_uri_ios": "https://apps.apple.com/app/id504288371",
"cities": [{
"uid": 50,
"lat": X,
"lng": X,
"zoom": 12,
"maps_icon": "",
"alias": "duesseldorf",
"break": false,
"name": "Düsseldorf",
"num_places": 875,
"refresh_rate": "10120",
"bounds": {
"south_west": {
"lat": X,
"lng": X
},
"north_east": {
"lat": X,
"lng": X
}
},
"booked_bikes": 4,
"set_point_bikes": 1111,
"available_bikes": 881,
"return_to_official_only": false,
"bike_types": {
"71": 10,
"150": 4,
"196": 880
},
"website": "https://www.nextbike.de/de/duesseldorf/",
"places": [{
"uid": 191740671,
"lat": X,
"lng": X,
"bike": true,
"name": "BIKE 30845",
"address": null,
"spot": false,
"number": 0,
"booked_bikes": 0,
"bikes": 1,
"bikes_available_to_rent": 1,
"bike_racks": 0,
"free_racks": 0,
"special_racks": 0,
"free_special_racks": 0,
"maintenance": false,
"terminal_type": "",
"bike_list": [{
"number": "30845",
"bike_type": 196,
"lock_types": ["frame_lock"],
"active": true,
"state": "ok",
"electric_lock": true,
"boardcomputer": 7551119754,
"pedelec_battery": null,
"battery_pack": null
}],
"bike_numbers": ["30845"],
"bike_types": {
"196": 1
},
"place_type": "12",
"rack_locks": false,
"dist": 26.449771934971892
}, {
"uid": 191781099,
"lat": X,
"lng": X,
"bike": true,
"name": "BIKE 31878",
"address": null,
"spot": false,
"number": 0,
"booked_bikes": 0,
"bikes": 1,
"bikes_available_to_rent": 1,
"bike_racks": 0,
"free_racks": 0,
"special_racks": 0,
"free_special_racks": 0,
"maintenance": false,
"terminal_type": "",
"bike_list": [{
"number": "31878",
"bike_type": 196,
"lock_types": ["frame_lock"],
"active": true,
"state": "ok",
"electric_lock": true,
"boardcomputer": 7551120099,
"pedelec_battery": null,
"battery_pack": null
}],
"bike_numbers": ["31878"],
"bike_types": {
"196": 1
},
"place_type": "12",
"rack_locks": false,
"dist": 201.27450165924398
}, {
"uid": 1997,
"lat": X,
"lng": X,
"bike": false,
"name": "X",
"address": null,
"spot": true,
"number": 5028,
"booked_bikes": 0,
"bikes": 1,
"bikes_available_to_rent": 1,
"bike_racks": 0,
"free_racks": 0,
"special_racks": 0,
"free_special_racks": 0,
"maintenance": false,
"terminal_type": "free",
"bike_list": [{
"number": "302667",
"bike_type": 196,
"lock_types": ["frame_lock"],
"active": true,
"state": "ok",
"electric_lock": true,
"boardcomputer": 7551126170,
"pedelec_battery": null,
"battery_pack": null
}],
"bike_numbers": ["302667"],
"bike_types": {
"196": 1
},
"place_type": "0",
"rack_locks": false,
"dist": 295.28558168458204
}, {
"uid": 122769,
"lat": X,
"lng": X,
"bike": false,
"name": "X",
"address": null,
"spot": true,
"number": 5033,
"booked_bikes": 0,
"bikes": 1,
"bikes_available_to_rent": 1,
"bike_racks": 0,
"free_racks": 0,
"special_racks": 0,
"free_special_racks": 0,
"maintenance": false,
"terminal_type": "free",
"bike_list": [{
"number": "302536",
"bike_type": 196,
"lock_types": ["frame_lock"],
"active": true,
"state": "ok",
"electric_lock": true,
"boardcomputer": 7551126363,
"pedelec_battery": null,
"battery_pack": null
}],
"bike_numbers": ["302536"],
"bike_types": {
"196": 1
},
"place_type": "0",
"rack_locks": false,
"dist": 311.67147139313545
}, {
"uid": 28183578,
"lat": X,
"lng": X,
"bike": false,
"name": "Radstation",
"address": null,
"spot": true,
"number": 5017,
"booked_bikes": 0,
"bikes": 6,
"bikes_available_to_rent": 6,
"bike_racks": 0,
"free_racks": 0,
"special_racks": 0,
"free_special_racks": 0,
"maintenance": false,
"terminal_type": "free",
"bike_list": [{
"number": "31126",
"bike_type": 196,
"lock_types": ["frame_lock"],
"active": true,
"state": "ok",
"electric_lock": true,
"boardcomputer": 7551123618,
"pedelec_battery": null,
"battery_pack": null
}, {
"number": "32014",
"bike_type": 196,
"lock_types": ["frame_lock"],
"active": true,
"state": "ok",
"electric_lock": true,
"boardcomputer": 7551131048,
"pedelec_battery": null,
"battery_pack": null
}, {
"number": "303198",
"bike_type": 196,
"lock_types": ["frame_lock"],
"active": true,
"state": "ok",
"electric_lock": true,
"boardcomputer": 7551125349,
"pedelec_battery": null,
"battery_pack": null
}, {
"number": "303186",
"bike_type": 196,
"lock_types": ["frame_lock"],
"active": true,
"state": "ok",
"electric_lock": true,
"boardcomputer": 7551124281,
"pedelec_battery": null,
"battery_pack": null
}, {
"number": "302764",
"bike_type": 196,
"lock_types": ["frame_lock"],
"active": true,
"state": "ok",
"electric_lock": true,
"boardcomputer": 7551126281,
"pedelec_battery": null,
"battery_pack": null
}, {
"number": "302727",
"bike_type": 196,
"lock_types": ["frame_lock"],
"active": true,
"state": "ok",
"electric_lock": true,
"boardcomputer": 7551125066,
"pedelec_battery": null,
"battery_pack": null
}],
"bike_numbers": ["31126", "32014", "303198", "303186", "302764", "302727"],
"bike_types": {
"196": 6
},
"place_type": "0",
"rack_locks": false,
"dist": 391.75141637300896
}]
}]
}]
}
now I am trying to get the length of the array “places”, by using a Rest Sensor.
Is there any templating I can use?
Something like this:
value_template: "{{ value_json.countries[0].cities[0].places[0].length() }}"
Thank you