Imagine I had a local JSON file that looked like this:
var institutes ={"colleges":[{"name":"Massachusetts Institute of Technology","address":{"line1":"77 Massachusetts Ave","City":"Cambridge","state":"Massachusetts","zip":"02139"},"phone":"(617) 253-2139","courses":["Computer Science","Mathematics","Physics"]},{"name":"Boston College","address":{"line1":"140 Commonwealth Drive","City":"Chestnut Hill","state":"Massachusetts","zip":"(617) 552-8000"},"phone":"(617) 253-8000","courses":["Law","Nursing","Theology"]},{"name":"UC Berkeley College","address":{"line1":"320 Mclaughlin Hall","City":"Berkeley","state":"California","zip":"92139"},"phone":"(510) 642-5771","courses":["Computer Science","Business Administration","Theology"]}]};
How would I write a search function that could potentially traverse through the entirety, looking at various keys to grab a query perimeter and return the most relevant objects using JavaScript only? For example, if my function were called search() and I perform the following call:
search("mass");
It would return me something like the following:
{"search results":{"entities_found":2,"highlights":4},"colleges":[{"name":"<span class='highlight'>Mass</span>achusetts Institute of Technology","address":{"line1":"77 <span class='highlight'>Massa</span>chusetts Ave","City":"Cambridge","state":"<span class='highlight'>Mass</span>achusetts","zip":"02139"},"phone":"(617) 253-2139","courses":["Computer Science","Mathematics","Physics"]},{"name":"Boston College","address":{"line1":"140 Commonwealth Drive","City":"Chestnut Hill","state":"<span class='highlight'>Mass</span>achusetts","zip":"(617) 552-8000"},"phone":"(617) 253-8000","courses":["Law","Nursing","Theology"]}};
Your daily driver? Weird, seeing that you don't seem to understand how your own browser downloads and installs its updates. What you posted earlier is factually incorrect...
Just now I downloaded MCT and created an ISO
C:\Windows\System32>dism /Get-WimInfo /WimFile:D:\sources\install.esd /index:6
Deployment Image Servicing and Management tool
Version: 10.0.26100.8521
Details for image : D:\sources\install.esd
Index : 6
Name : Windows 11 Pro
Description : Windows 11 Pro
Size : 25,471,900,045 bytes
WIM Bootable : No
Architecture : x64
Hal :
Version : 10.0.26200
ServicePack Build : 8653
ServicePack Level : 0
Edition : Professional
Installation : Client
ProductType : WinNT
ProductSuite : Terminal Server
System Root : WINDOWS
Directories : 33220
Files : 147525
Created : 2026-06-05 - 11:28:55 PM
Modified : 2026-06-12 - 5:56:11 PM
Languages :
en-US (Default)
The operation completed successfully.
Question
Brian Miller
Imagine I had a local JSON file that looked like this:
How would I write a search function that could potentially traverse through the entirety, looking at various keys to grab a query perimeter and return the most relevant objects using JavaScript only? For example, if my function were called search() and I perform the following call:
It would return me something like the following:
Equally, if I were to search for the following:
I would get this:
Link to comment
https://www.neowin.net/forum/topic/1435030-js-searching-thought-local-json-file/Share on other sites
6 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now