Skip to content

Conversation

@csWen
Copy link

@csWen csWen commented Jul 18, 2025

Summary

This PR fixes a config path issue and adds JSONPath filtering.

Problems Solved

I encountered two problems while using xdiff:

  1. Custom config paths didn't work: The --config parameter wasn't resolving paths correctly
  2. Large JSON responses were overwhelming: I needed a way to compare only specific fields instead of entire JSON objects

Changes

Config Path Fix

  • Fixed --config parameter to properly resolve custom configuration file paths

JSONPath Filtering Support

  • Added --jsonpath CLI parameter to extract specific JSON fields before comparison
  • Added jsonpath support in YAML config files
  • Supports expressions like $.title, $.containers[*].slug, $.users[?(@.active == true)]

Usage

Command line:

xdiff run -p profile -c config.yml --jsonpath "$.user.hobbies[*].name"

Config file:

response:
  skip_headers: [date, etag]
  jsonpath: "$.user.hobbies[*].name"

- fix: resolve --config parameter path resolution issues
- feat: add JSONPath filtering for targeted JSON field comparison
- feat: support JSONPath in both CLI (--jsonpath) and config files
- docs: update README with JSONPath usage examples and patterns

This addresses two key usability issues:
1. Custom config paths via --config now work reliably
2. Large JSON responses can be filtered to compare only specific fields
   using JSONPath expressions like $.containers[*].slug

Uses jsonpath-rust crate (RFC 9535 compliant) for robust JSON processing.

Maintains full backward compatibility with existing functionality.
@csWen csWen requested a review from tyrchen July 18, 2025 05:39
- Run cargo fmt to fix formatting issues for CI
- Update version to 0.5.0 for JSONPath feature and config fix
- Sync dependency versions across workspace
@csWen csWen force-pushed the feat/config-fix-and-jsonpath-support branch from 2e881da to 81c8ee3 Compare July 18, 2025 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants