-
Notifications
You must be signed in to change notification settings - Fork 215
Open
Description
given the code below:
var jp = require("jsonpath")
var data = {
"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
}
}
}
var nodes = jp.apply(data, '$..author', function(value) { return value.toUpperCase() });
console.log(nodes)Expected:
[
{"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"}
]Actual:
[
{"path":["$","store","book",0],"value":"NIGEL REES"},
{"path":["$","store","book",1],"value":"EVELYN WAUGH"},
{"path":["$","store","book",2],"value":"HERMAN MELVILLE"},
{"path":["$","store","book",3],"value":"J. R. R. TOLKIEN"}
]Runkit example: https://runkit.com/psygik/6538cdcc485c4f000831f0dc
Metadata
Metadata
Assignees
Labels
No labels