DEV Community

Discussion on: How To Create A Global "JSON Search Algorithm" In JavaScript.

Collapse
 
haidarknightfury profile image
Haidar

Yes but not really scalable. What if you have more than 3 level of nesting. I think you could improve your function a bit

Thread Thread
 
johnkazer profile image
John Kazer

There's a library called fusejs that flattens out objects with nested arrays. It checks the type of each value and if array recurses. All in order to create one big flat object you can search in.

Thread Thread
 
emmaccen profile image
Lucius Emmanuel Emmaccen

Thanks for sharing John.

Thread Thread
 
johnkazer profile image
John Kazer

You might find fusejs interesting as a search library - the "flattening" process is part of how it searches rather than main function.