Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON field transformation #163

Merged
merged 1 commit into from
Aug 10, 2023

Conversation

Mikescops
Copy link
Member

This PR allows to use JSONPath transformation on fields.

Given this JSON file:

You can do such operations:

{
"store": {
  "book": [
    {
      "category": "reference",
      "author": "Nigel Rees",
      "title": "Sayings of the Century",
      "price": 8.95
    },
    {
      "category": "fiction",
      "author": "Evelyn Waugh",
      "title": "Sword of Honour",
      "price": 12.99
    },
    {
      "category": "fiction",
      "author": "Herman Melville",
      "title": "Moby Dick",
      "isbn": "0-553-21311-3",
      "price": 8.99
    },
    {
      "category": "fiction",
      "author": "J. R. R. Tolkien",
      "title": "The Lord of the Rings",
      "isbn": "0-395-19395-8",
      "price": 22.99
    }
  ],
  "bicycle": {
    "color": "red",
    "price": 19.95
  }
}
}
dcli read 'dl://books.json/content?json=$..*[?(@property === "price" && @ !== 8.95)]'
[19.95,12.99,8.99,22.99]

JSONPath system (quite similar to jq) is explained here: https://github.com/JSONPath-Plus/JSONPath#syntax-through-examples

@Mikescops Mikescops added the features New feature or request label Aug 10, 2023
@Mikescops Mikescops requested a review from showi August 10, 2023 11:18
@Mikescops Mikescops self-assigned this Aug 10, 2023
@Mikescops Mikescops merged commit 7f7e3bb into master Aug 10, 2023
1 check passed
@Mikescops Mikescops deleted the feature/add-json-field-transformation branch August 10, 2023 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
features New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants