Recently, I've been working with a json array that dynamically increases based on user input. Here's a snippet of the json code I'm dealing with:
[{"scheduleid":"randomid","datestart":"2020-06-30","dateend":"2020-06-30","timestart":"08:00","timeend":"20:00","recurrences":"dailysett","daily":""},
{"scheduleid":"randomid2","datestart":"2020-06-30","dateend":"2020-06-30","timestart":"08:00","timeend":"20:00","recurrences":"dailysett","daily":""}]
This json array is stored in var Schedulearray
. If I need to search for a specific id, such as retrieving randomid
from the array, I can use the following line of code:
Schedulearray.scheduleid;
If the result is randomid
, I'd like to retrieve all attributes associated with that element, like timestart, timeend, and so on. Is it possible to do this in one go, or do I have to fetch each attribute individually like demonstrated below?
var timestart=Schedulearray.timestart;