https://github.com/triggerdotdev/fuzzy-json-search
Search a JSON document by path, content, and inferred content
https://github.com/triggerdotdev/fuzzy-json-search
Last synced: 2 days ago
JSON representation
Search a JSON document by path, content, and inferred content
- Host: GitHub
- URL: https://github.com/triggerdotdev/fuzzy-json-search
- Owner: triggerdotdev
- License: mit
- Created: 2022-04-06T10:56:55.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-14T17:05:38.000Z (over 1 year ago)
- Last Synced: 2025-04-09T02:58:46.216Z (8 days ago)
- Language: TypeScript
- Size: 534 KB
- Stars: 17
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - triggerdotdev/fuzzy-json-search - Search a JSON document by path, content, and inferred content (TypeScript)
README
# Fuzzy JSON Search
> VSCode style fuzzy search for JSON documents
## 🚀 Features
- Use VSCode style fuzzy search on a JSON document
- Searches through key names, path, raw values and formatted values## 💻 Usage
Install Fuzzy JSON Search
```bash
$ 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:
```typescript
const response = await fetch("https://jsonplaceholder.typicode.com/todos");
const json = await response.json();const searcher = new JSONHeroSearch(json);
const results = searcher.search("user");
```## API
### `JSONHeroSearch.search(query: string)`
Performs a fuzzy search against the entire document, ordering by score. Will only return results that score more than 0.
#### Returns `Array>>`
`SearchResult` has the following properties:
##### `item` is a `string` representing the path to the key
##### `score` is an `ItemScore`
##### `ItemScore` has the following properties
##### `score` is a number, the higher the score the better a match
##### `labelMatch` is an array of `Match` objects
##### `descriptionMatch` is an array of `Match` objects
##### `rawValueMatch` is an array of `Match` objects
##### `formattedValueMatch` is an array of `Match` objects
##### `Match` is type `{ start: number; end: number }`