Use JMESPath instead of JSONPath for response filtering

JSONPath is widely used but behaviour varies between implementations.

JMESPath has consistent official implementations in multiple languages.

JMESPath is far more capable. For example JSONPath cannot pull fields out of nested objects like this:

Response:

[  {    "id": 123,    "category": {      "id": 1,      "name": "dog"    },    "name": "Rover"  },  {    "id": 456,    "category": {      "id": 1,      "name": "fish"    },    "name": "fishy"  }]

JMESPath filter: [].{name:name,category:category.name}

Result:

[  {    "name": "Rover",    "category": "dog"  },  {    "name": "fishy",    "category": "fish"  }]

Thanks

Please authenticate to join the conversation.

Upvoters
Status

Needs Triage

Board

Feedback

Tags

Improvement

Date

10 months ago

Author

Hamish Robertson

Subscribe to post

Get notified by email when there are changes.