I am trying to implement a search function where I search through all values in a JSON object without knowing the keys beforehand.
It goes something like this:
object.where((o) => o['name'].contains(searchString))
but notice that I have to specify the key ‘name’ to search through this part of the JSON. I want to be able to search through the entire JSON object and I don’t know what the keys would be ahead of time.
Is there a way to do this?
2
Answers
If I understand you correctly, what you need is only traversing all values:
Another approach could be
but I’m not sure about the structure of your map