hai all.
this is my server response and i want to extract only the switchID
{"Data":[{"userID":"101","switchID":"abc123","switchStatus":"0"},{"userID":"101","switchID":"efg456","switchStatus":"0"}]}
which is in json format
can any one tell me the approach that i should follow or if i get the logical blocks
that will be more useful for me.
hai, how can i extract all the switchID's and have extracted switchID's in an array .
there are 2 switchID's but now i am able to extract only first switchID.
{"Data":[{"userID":"101","switchID":"abc123","switchStatus":"0"},{"userID":"101","switchID":"efg456","switchStatus":"0"}]}
i need all the switchID's to be extracted and stored in an array no matter how many switchID's my server response displays.
No problem with that because my logic works such a way that my server responses based on the userID that i have sent .
All the needed was too get all the switchID.
The former will return the value "abc123" in your example data or "not found" if nothing is found. The latter will return ["abc123", "efg456"] or [] if there were no data. The blocks are slightly more compact and they also prevent the potential logic bug of looking up a value in the middle that doesn't exist and causing the code to error out.