@jsonhero/fuzzy-json-search
Advanced tools
VSCode style fuzzy search for JSON documents
Weekly downloads
Changelog
Export the scoreFuzzy function
Readme
VSCode style fuzzy search for JSON documents
Install Fuzzy JSON Search
$ npm install --save @jsonhero/fuzzy-json-search
The simplest way to search is to create an instance of JSONHeroSearch
and pass it a JSON object:
const response = await fetch("https://jsonplaceholder.typicode.com/todos");
const json = await response.json();
const searcher = new JSONHeroSearch(json);
const results = searcher.search("user");
JSONHeroSearch.search(query: string)
Performs a fuzzy search against the entire document, ordering by score. Will only return results that score more than 0.
Array<SearchResult<string>>>
SearchResult<string>
has the following properties:
item
is a string
representing the path to the keyscore
is an ItemScore
ItemScore
has the following propertiesscore
is a number, the higher the score the better a matchlabelMatch
is an array of Match
objectsdescriptionMatch
is an array of Match
objectsrawValueMatch
is an array of Match
objectsformattedValueMatch
is an array of Match
objectsMatch
is type { start: number; end: number }