How JSON Filtering Works
When you apply a JSON filter, changedetection.io:- Fetches the content from the URL
- Parses the JSON (either pure JSON or extracts it from HTML)
- Applies your filter to extract specific values
- Formats the output for monitoring
- Detects changes in the extracted data
- Monitor API responses for changes
- Extract nested data structures
- Filter and transform JSON data
- Parse JSON embedded in HTML (like LD+JSON)
- Use logical operations to filter results
Filtering Methods
changedetection.io supports three JSON filtering syntaxes:- JSONPath
- jq
- jq (Raw Output)
Prefix:
json:Library: jsonpath-ngBest for: Simple to moderate JSON queriesExample:JSONPath Syntax
Basic Selection
price fields at any level.
Array Access
Filtering
jq Syntax
Basic Selection
Filtering with select()
Transformations
Practical Examples
Monitor API Price
Extract Multiple Fields
- JSONPath
- jq
Monitor Array of Items
Embedded JSON in HTML
changedetection.io can automatically extract and parse JSON embedded in HTML pages, particularly useful for:- LD+JSON (Linked Data JSON) - Structured data for SEO
- Application State - JavaScript state stored in script tags
- API Data - JSON embedded for client-side rendering
LD+JSON Product Data
changedetection.io automatically detects and parses
<script type="application/ld+json"> tags. Just use your JSON filter as if you were querying the JSON directly.Multiple JSON Blocks
If the HTML contains multiple JSON blocks:Advanced Filtering
Filter by Multiple Conditions (jq)
Filter by Multiple Conditions (jq)
Nested Data Extraction
Nested Data Extraction
Array Transformations (jq)
Array Transformations (jq)
Conditional Output (jq)
Conditional Output (jq)
Output Formatting
Single Value
When your filter returns a single value:29.99 (unquoted number)
Multiple Values
When your filter returns multiple values:String Values
"Gaming Laptop" (includes quotes)
Use jqraw: prefix to get unquoted strings:
Gaming Laptop
Testing JSON Filters
Using Online Tools
JSONPath:- JSONPath Online Evaluator
- Paste your JSON and test expressions
- jq play
- Interactive jq playground
Using Browser Console
- Open DevTools Console (F12)
- Fetch and test your JSON:
- Examine structure and test paths
Common Patterns
Pattern: Extract Nested Price
Pattern: Monitor Stock Status
Pattern: Track Multiple Products
Pattern: Filter Price Range (jq)
Pattern: Count Items (jq)
Common Pitfalls
When to Use JSON Filtering
Good for:
- Monitoring REST APIs
- Tracking prices from JSON endpoints
- Extracting structured data from HTML (LD+JSON)
- Processing JSON with logical filtering
- Monitoring nested data structures
Not ideal for:
- HTML content (use CSS selectors or XPath)
- XML/RSS feeds (use XPath)
- Plain text content
JSONPath vs jq
| Feature | JSONPath | jq |
|---|---|---|
| Syntax complexity | Simpler | More powerful |
| Platform support | ✅ All platforms | ❌ May not work on Windows |
| Filtering | Basic [?(@.x)] | Advanced select() |
| Transformations | Limited | Extensive (map, group, etc.) |
| Learning curve | Easier | Steeper |
| Output formatting | Automatic | Full control |
| Math operations | ❌ No | ✅ Yes (add, multiply, etc.) |
Real-World Examples
Example: Monitor GitHub API
Example: Monitor GitHub API
Example: Track Cryptocurrency Price
Example: Track Cryptocurrency Price
Example: Monitor E-commerce Inventory
Example: Monitor E-commerce Inventory
Example: Track Weather Data
Example: Track Weather Data
Example: Monitor Job Postings API
Example: Monitor Job Postings API
Combining with Other Filters
You can combine JSON filtering with other features:Ignore Text
After extracting JSON data, filter out unwanted values: Filter:json:$.products[*].name
Ignore text: Discontinued
Trigger Keywords
Trigger only when specific values appear: Filter:json:$.status
Trigger text: Available, In Stock
Extract Text (Regex)
Further process extracted JSON values: Filter:json:$.price
Extract text: /\d+\.\d{2}/ (extract just the number)
Debugging Tips
No Output
- Verify URL returns valid JSON (check in browser)
- Test filter in online JSONPath/jq playground
- Check for typos in property names
- Try recursive descent:
$..property - Enable browser-based fetching if JSON is loaded dynamically
Unexpected Output Format
- Single value returns without array brackets
- Multiple values return as JSON array
- Use
jqraw:for unquoted string output - Check if your path is too broad (
$..pricefinds ALL prices)
Parsing Errors
- Ensure content-type is JSON or contains valid JSON
- Check for BOM (Byte Order Mark) issues
- Verify JSON is not wrapped in extra markup
- For HTML-embedded JSON, ensure
<script type="application/ld+json">is correct
Related Topics
- CSS Selectors - Extract HTML content
- XPath - Query XML and RSS feeds
- API Monitoring - Best practices for monitoring APIs