var nodes = jp.apply(data, '$..author', function(value) { return value.toUpperCase() });
// [
// { path: ['$', 'store', 'book', 0, 'author'], value: 'NIGEL REES' },
// { path: ['$', 'store', 'book', 1, 'author'], value: 'EVELYN WAUGH' },
// { path: ['$', 'store', 'book', 2, 'author'], value: 'HERMAN MELVILLE' },
// { path: ['$', 'store', 'book', 3, 'author'], value: 'J. R. R. TOLKIEN' }
// ]
Have something similar to https://github.com/dchester/jsonpath#jpapplyobj-pathexpression-fn in our jsonpath package
/kind feature
/help-wanted
/help
I saw you guys need help from a contributor. I would like to help. Although I don't really understand what's exactly the problem is
@mengqiy can you elaborate ^^?
I'd imagine it have something like:
Given a jsonpath string and modifier function func(interface{}) interface{}.
Our jsonpath lib should provide the ability to apply the modifier function to the node(s) specified by the jsonpath.
For example, given the following json object
{
"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
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
And having the modifier function and jsonpath
jsonpath := "$.store.book[1].author"
fn := func(in interface{}) interface{} {
s := in.(string)
return strings.ToUpper(s)
}
md5-83224704915a9e50e148af92ae315e8d
{
"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
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
IMO this does not belong into client-go. We are not a json library. If we want more, either we use another library or we split out the jsonpath package from client-go in its own project.
Also compare https://github.com/kubernetes/kubernetes/blob/1db0024ec99cb2e4a2154df22008c27b344190e0/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/jsonpath_test.go, yet another internal jsonpath library. All that should go into k8s.io/jsonpath or similar.
All that should go into k8s.io/jsonpath or similar.
Is this still a "help wanted" issue? Removing help-wanted for now.
/remove-help
Maybe not.
Creating a new repo in the org is non-trivial. This issue may be not easy for new contributors.
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
@fejta-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue with/reopen.
Mark the issue as fresh with/remove-lifecycle rotten.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Most helpful comment
Also compare https://github.com/kubernetes/kubernetes/blob/1db0024ec99cb2e4a2154df22008c27b344190e0/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/jsonpath_test.go, yet another internal jsonpath library. All that should go into k8s.io/jsonpath or similar.