ArduinoJson icon indicating copy to clipboard operation
ArduinoJson copied to clipboard

Find out the first appearance of an element in JsonArray

Open voanhcuoc opened this issue 6 years ago • 1 comments

I have read through the API docs but didn't find such a basic functionality so I have to implement my own. A containsElement method would help:

jsonArray.containsElement<String>("third") // == 2 . find out at index 2
jsonArray.containsElement<String>("none") // == -1 . didn't find out

voanhcuoc avatar Dec 01 '19 01:12 voanhcuoc

I think indexOf() would be a more accurate name.

bblanchon avatar Dec 02 '19 17:12 bblanchon

You can easily implement this with a loop; no need to clutter the library.

bblanchon avatar Feb 24 '23 08:02 bblanchon