ijse / jsonpath Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/jsonpath
Automatically exported from code.google.com/p/jsonpath
What steps will reproduce the problem?
1. Using this object
{"@position": '18',
"@unid": '29CD471ED18EE9B88725740E0006853D',
"@noteid": '982',
"@siblings": 51,
entrydata: [
{
"@columnnumber": 0,
"@name": 'first',
text: {
0: 'test3'
}
},
{
"@columnnumber": 1,
"@name": 'last',
text: {
0: 'last3'
}
},
{
"@columnnumber": 2,
"@name": 'company',
text: {
0: 'company3'
}
},
{
"@columnnumber": 3,
"@name": 'email',
text: {
0: '[email protected]'
}
},
{
"@columnnumber": 4,
"@name": 'time',
text: {
0: '3:00 PM'
}
}
]
}
2. using this xpath does not work
jsonPath(obj, "entrydata[?(@['@name']=='first')].text[0]")
3. if I rename the property '@name' to 'name' it works
I am working with a server side response that i cannot alter... any ideas?
Original issue reported on code.google.com by [email protected]
on 17 Mar 2008 at 7:24
What steps will reproduce the problem?
1. Use a json that contain a dictionary with a key that contains a dot (for
example: {'34.3': 'value'} )
2. Try to query from the dictionary key with a dot (for example $.['34.3'])
3. Nothing will be found (but if '34.3' was '34_3', then it'd work)
What is the expected output? What do you see instead?
It should be able to query dictionary keys containing dots inside, but it isn't.
What version of the product are you using? On what operating system?
Python 2.7 with the latest version of the JsonPath library
Please provide any additional information below.
It seem that when I try to query something like "$['34.4']" it is transformed
into "$.34.4" before querying, which causes the problem
Original issue reported on code.google.com by [email protected]
on 4 Jul 2014 at 1:25
Ported this to Perl, VALUE works fine, PATH option is not fully functional
though.
Additionally I've added "!" as a special character which will list all the
keys in the hash pointed to by hash indicated in the JSONPath expression.
Latest version, and documentation notes, available here:
http://github.com/masukomi/jsonpath-perl/tree/master
Original issue reported on code.google.com by [email protected]
on 27 Oct 2008 at 4:16
Set a default value for vname. It is never used in the function, but without it
earlier trace functions might not work.
Original issue reported on code.google.com by [email protected]
on 17 Aug 2012 at 7:04
Attachments:
What steps will reproduce the problem?
jsonPath(json_decode('{ "data1": "value"}'), "$.data1");
What is the expected output? What do you see instead?
expected: array("value")
returned: false
What version of the product are you using? On what operating system?
0.8.1
Please provide any additional information below.
jsonPath(json_decode('{ "data1": "value"}', true), "$.data1"); works fine
because the json is decoded as an array.
it seems like json decoded in object (stdclass) doesn't work.
Original issue reported on code.google.com by [email protected]
on 17 Feb 2015 at 12:23
What steps will reproduce the problem?
1. Include jsonpath.js file
2. Try to parse any .json file
3. display returned json data
What is the expected output? What do you see instead?
JSON text
false
What version of the product are you using? On what operating system?
jsonpath-0.8.0.js
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 25 Jul 2015 at 7:58
What steps will reproduce the problem?
1. open jp.html
2. check output of
out += jsonPath(apps, "$.organizations[?(@.name=='[email protected]')]..apps").toJSONString() + "\n";
3. false does not make sense.
What is the expected output? What do you see instead?
expect - [{
"name":"bars",
"apps":[{ "name":"bara",
"version":"1"
}]
}]
What version of the product are you using? On what operating system?
jsonpath 0.8
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 9 Apr 2014 at 3:26
What steps will reproduce the problem?
1. Member names in pathes containing dot '.' should work, if it is enclosed
in single quotes, as in {{{$['a.b']}}}.
Original issue reported on code.google.com by [email protected]
on 19 Sep 2007 at 1:11
Parent operator needed
Original issue reported on code.google.com by [email protected]
on 3 Aug 2010 at 12:43
What steps will reproduce the problem?
==call==
jsonPath(self, '$..DIV[?(@.@class==\'value\')]').length
==input==
var arr={ "DIV": [{"@class":"value","val":5}] };
What is the expected output? What do you see instead?
Expected 1, returned 0
What version of the product are you using? On what operating system?
jsonpath-0.8.0.js
¡Javascript!
Please provide any additional information below.
The problem is about notation. In the notation, "@" has the meaning of
actual object but an attribute starting with "@" is handled as actual
object. I suggest to change the "@" simbol for another that is reserved in
XML.
I suggest to visit: "http://www.w3.org/TR/xml/#NT-NameChar" for change the
symbol.
Original issue reported on code.google.com by [email protected]
on 13 Aug 2009 at 10:57
What steps will reproduce the problem?
Using "$" as path expression to the object root results in "no match".
What is the expected output?
the complete object.
What do you see instead?
"no match"
Original issue reported on code.google.com by [email protected]
on 19 Dec 2007 at 2:41
Having the test page tests/jsonpath-test-js.html show a variety of example
objects, expressions and results is really useful.
To make sense of it you need to review the output of the page (in a browser) -
which only shows the results - side-by-side with the HTML source.
The attached is an attempt to put all the useful information in the viewable
page - namely what the source data object was and the input expression. Further
to this I've included the expectations to potentially allow for regression
testing - e.g. comparison of behaviour for different jsonpath.js versions by
seeing what "fails" the expected vs actual test.
So in summary, starting with the jsonpath-test-js.html, the changes in the
attached include:
- reference to jsonpath.js is relative from /tests (../src/js/jsonpath.js)
- removed reference to json.js and using JSON.stringify(..) instead
- display (in tabular layout) the source data, expression and results
- structure of the test data changed to be (excuse the made up JSON schema):
var suite = [ <test-objects> ];
<test-object>: {
"comment": <optional test comment>,
"data": <source object>,
"tests": [ <expression-test-objects> ]
}
<expression-test-objects>: {
"expr": <jsonpath expression>,
"comment": <optional expression comment>,
"paths": [ <expected PATH result as 0-to-many paths> ],
"values": [ <expected VALUE result as 0-to-many paths> ]
}
- each expression test runs the path and value tests separately and compares
the results with the expectations. This is different to jsonpath-test-js.html
which only obtained the "PATH" result then obtained the values via 'evaluate'.
Presently, there's one test failing the "VALUE" result (Test #2, Expression
#1).
- if a comparison between expected & actual fails, the actual result is
stringified onto the page (perhaps to help update expectations)
- no-result 'false' is turned into empty array []
- added in the 'bookstore' data and example expressions and expectations from
the Wiki
I'm hoping someone else finds this useful ...
Consider for inclusion in the project? Potentially, new issues could be
captured as new "<test-object>" definitions - showing the expectation, and the
page will show if it fails.
Original issue reported on code.google.com by [email protected]
on 16 Jul 2013 at 2:46
Attachments:
What steps will reproduce the problem?
$data = array('foo' => array('a', 'b'))
jsonPath($data, '$.foo.0') returns the wrong result
What is the expected output? What do you see instead?
Expected output is array(0 => 'a')
Actual output is array(array(0 => 'a'))
What version of the product are you using? On what operating system?
jsonPath0.8.1.php on linux
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 8 Sep 2011 at 10:29
array slice syntax with PHP file doesn't work properly.
Original issue reported on code.google.com by [email protected]
on 7 Sep 2007 at 11:52
In the PHP library the evalx() method as a $vname argument that is never
used and is causing an error when using expressions such as:
[?(@['id']>2)]
The extra argument should be removed.
Original issue reported on code.google.com by [email protected]
on 13 Sep 2008 at 3:21
With the resolution of Issue 6 in 0.8.4 I can now do
jsonPath({'x': {'y': 'z', 'yy': 'zz'}}, "$")
to get back 'x' and $.x.y to get 'z'
Question: how do I reference 'y' i.e. the first key 'in' x?
I'm pretty sure there is an equivalent in xpath..?
Original issue reported on code.google.com by [email protected]
on 22 Nov 2009 at 8:29
In larger JSON framework, for jsonpath analysis
it might be usefull to have more resultTypes:
* normalized path - just steps of path as an array
(w/out tracing target object)
if( P.resultType == "WAY" ) return P.normalize(expr).split(';');
P.trace(P.normalize(expr).replace(/^\$;/,""), obj, "$");
return P.result.length ? P.result : false;
* normalized traced path - with expanded expressions/filters/slices
asTrace: function(path) { return path.split(";"); }
store: function(p, v) {
if (p) P.result[P.result.length] =
( P.resultType == "PATH" ? P.asPath(p) :
( P.resultType == "TRACE" ? P.asTrace(p) : v));
return !!p;
},
Original issue reported on code.google.com by [email protected]
on 4 Nov 2009 at 12:19
Attempting to access a property value with an @ sign.
The query is dynamically built and needs to be able to evaluate any string.
What steps will reproduce the problem?
1. Using this object
{
"report": {
"Author": [
{
"value": "John",
"count": "58",
"fields": [
{
"key": "FileSize",
"value": "12314"
},
{
"key": "Date",
"value": "2000-01-01"
}
]
},
{
"value": "Jane",
"count": "1",
"fields": [
]
},
{
"value": "[email protected]",
"count": "58",
"fields": [
{
"key": "FileSize",
"value": "12314"
},
{
"key": "Date",
"value": "2000-01-01"
},
{
"key": "tags",
"value": "a,b,c,d"
}
]
},
{
"value": "Bill",
"count": "2",
"fields": [
{
"key": "FileSize",
"value": "14"
}
]
}
]
}
}
2. Using this path
$.report.Author[?(@.value==='[email protected]')]
What is the expected output? What do you see instead?
Expected - [{
"value": "[email protected]",
"count": "58",
"fields": [
{
"key": "FileSize",
"value": "12314"
},
{
"key": "Date",
"value": "2000-01-01"
},
{
"key": "tags",
"value": "a,b,c,d"
}
]
}]
Actual result - False
What version of the product are you using? On what operating system?
JSONPath 0.8.0
Windows Server 2008 R2 - IIS 7.5
Please provide any additional information below.
I've also tried
$.report.Author[?(@.value==='\[email protected]\')] with no luck.
Since the value can actually be any string I can't escape in string.
Original issue reported on code.google.com by [email protected]
on 1 Oct 2012 at 7:02
Based on JavaScript and Perl versions.
http://www.ultimate.com/phil/python/
http://pypi.python.org/pypi/jsonpath/
Original issue reported on code.google.com by [email protected]
on 28 Apr 2009 at 9:13
For Issue 7, the code looks explicitly for \\@ as an escaped element in the
field name. This is a great feature that should be expanded to include other
characters that need to be escaped, like dash ('-'). It is common to have
dashes in field names:
{
"first-name" : "Matt",
"last-name" : "Bishop"
}
Original issue reported on code.google.com by [email protected]
on 13 Dec 2011 at 9:17
What steps will reproduce the problem?
1. Using a path expression which contains '[0]' yields wrong results.
Original issue reported on code.google.com by [email protected]
on 16 Sep 2007 at 9:41
Hi Stefan
I have now find the correct place for Jsonpath issues!
I have posted a mini demo here:
https://github.com/sailfishapps/ThrowawayDemos/blob/master/Kaputt/JsonDBDemo
This runs on Sailfish using Qt QML / Javascript
The json file has 3 entities / elements, landed, area and template. Landed is
the root, and template is a child of area.
The json file has 3 areas, each with 2 child templates.
If I apply the following query:
$.landed.area[?(@.id = 1)].template[*]
I expect to get only the templates that belong to the area with id 1. (i.e. 2
hits)
Instead I get all templates of all areas. (i.e. 6 hits)
I am running jsonpath 0.8.5
As a first step to understanding what your code is doing, I have added some
console.log calls to the trace function.
The output shows that template is being processed 3 times (once for each area).
I expect it to be processed only once due to the predicate on area.
Grüsse
Chris
[email protected]
//start json file
{
"landed":{
"area":[
{
"id":1,
"name":"South Africa",
"template":[
{
"id":1,
"name":"DefaultOKMsg"
},
{
"id":2,
"name":"DefaultNotOKMsg"
}
]
},
{
"id":3,
"name":"Schweiz",
"template":[
{
"id":1,
"name":"DefaultOKMsg"
},
{
"id":2,
"name":"DefaultNotOKMsg"
}
]
},
{
"id":4,
"name":"Italia",
"template":[
{
"id":1,
"name":"DefaultOKMsg"
},
{
"id":2,
"name":"DefaultNotOKMsg"
}
]
}
]
}
}
//end json file
//start console. log output
[D] getTemplates:50 - getting Templates for area: undefined
[D] parseJSONString:12 - about to pass DB to JSONPath
[D] P.trace:33 - trace: expr:landed;area;?(@.id = 1);template;*
[D] P.trace:34 - trace: val:[object Object]
[D] P.trace:35 - trace: path:$
[D] P.trace:33 - trace: expr:area;?(@.id = 1);template;*
[D] P.trace:34 - trace: val:[object Object]
[D] P.trace:35 - trace: path:$;landed
[D] P.trace:33 - trace: expr:?(@.id = 1);template;*
[D] P.trace:34 - trace: val:[object Object],[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area
[D] P.trace:33 - trace: expr:0;template;*
[D] P.trace:34 - trace: val:[object Object],[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area
[D] P.trace:33 - trace: expr:template;*
[D] P.trace:34 - trace: val:[object Object]
[D] P.trace:35 - trace: path:$;landed;area;0
[D] P.trace:33 - trace: expr:*
[D] P.trace:34 - trace: val:[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area;0;template
[D] P.trace:33 - trace: expr:0;
[D] P.trace:34 - trace: val:[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area;0;template
[D] P.trace:33 - trace: expr:
[D] P.trace:34 - trace: val:[object Object]
[D] P.trace:35 - trace: path:$;landed;area;0;template;0
[D] P.trace:33 - trace: expr:1;
[D] P.trace:34 - trace: val:[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area;0;template
[D] P.trace:33 - trace: expr:
[D] P.trace:34 - trace: val:[object Object]
[D] P.trace:35 - trace: path:$;landed;area;0;template;1
[D] P.trace:33 - trace: expr:1;template;*
[D] P.trace:34 - trace: val:[object Object],[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area
[D] P.trace:33 - trace: expr:template;*
[D] P.trace:34 - trace: val:[object Object]
[D] P.trace:35 - trace: path:$;landed;area;1
[D] P.trace:33 - trace: expr:*
[D] P.trace:34 - trace: val:[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area;1;template
[D] P.trace:33 - trace: expr:0;
[D] P.trace:34 - trace: val:[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area;1;template
[D] P.trace:33 - trace: expr:
[D] P.trace:34 - trace: val:[object Object]
[D] P.trace:35 - trace: path:$;landed;area;1;template;0
[D] P.trace:33 - trace: expr:1;
[D] P.trace:34 - trace: val:[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area;1;template
[D] P.trace:33 - trace: expr:
[D] P.trace:34 - trace: val:[object Object]
[D] P.trace:35 - trace: path:$;landed;area;1;template;1
[D] P.trace:33 - trace: expr:2;template;*
[D] P.trace:34 - trace: val:[object Object],[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area
[D] P.trace:33 - trace: expr:template;*
[D] P.trace:34 - trace: val:[object Object]
[D] P.trace:35 - trace: path:$;landed;area;2
[D] P.trace:33 - trace: expr:*
[D] P.trace:34 - trace: val:[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area;2;template
[D] P.trace:33 - trace: expr:0;
[D] P.trace:34 - trace: val:[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area;2;template
[D] P.trace:33 - trace: expr:
[D] P.trace:34 - trace: val:[object Object]
[D] P.trace:35 - trace: path:$;landed;area;2;template;0
[D] P.trace:33 - trace: expr:1;
[D] P.trace:34 - trace: val:[object Object],[object Object]
[D] P.trace:35 - trace: path:$;landed;area;2;template
[D] P.trace:33 - trace: expr:
[D] P.trace:34 - trace: val:[object Object]
[D] P.trace:35 - trace: path:$;landed;area;2;template;1
[D] parseJSONString:14 - readDataModel.js: objectArray.length: 6
//end console.log output
Original issue reported on code.google.com by [email protected]
on 10 Feb 2014 at 9:55
I am wondering if there is a way to extract object names from a json file. I am
working with data from archive.org and they used file names as json object
names. i.e.
http://www.archive.org/details/gd1980-09-06.aud.morris.106620.flac24&output=json
files
I have been using http://jsonpath.curiousconcept.com/ to set my queries
I can get all the file objects with $.files
I can get the value of an atribute for all the file objects with
$.files.*.format
But what I want is the file names, which are the names of the file objects.
Original issue reported on code.google.com by [email protected]
on 3 Jan 2012 at 5:37
What steps will reproduce the problem?
==call==
jsonPath(arr, '$..book[?(@.isbn)]').length
==input==
var arr={ "store": {
"book": { "isbn": "0-553-21311-3"}
};
What is the expected output? What do you see instead?
Expected 1, returned 0
What version of the product are you using? On what operating system?
jsonpath-0.8.0.js
¡Javascript!
Please provide any additional information below.
The problem is that in the "trace" function, in the case of "[?(expr)]" the
function P.walk is applied for arrays but the simple case is not handled.
A temporal solution, that works is add a line of code to the "[?(expr)]" case:
----------Old code------------:
else if (/^\?\(.*?\)$/.test(loc)) // [?(expr)]
P.walk(loc, x, val, path, function(m,l,x,v,p) { if
(P.eval(l.replace(/^\?\((.*?)\)$/,"$1"),v[m],m)) P.trace(m+";"+x,v,p); });
----------New code------------:
else if (/^\?\(.*?\)$/.test(loc)){ // [?(expr)] Added curly brace, 2 lines
if (P.eval(loc.replace(/^\?\((.*?)\)$/,"$1"),val,null))
P.trace(x,val,path); //Added, to handle just this node
P.walk(loc, x, val, path, function(m,l,x,v,p) { if
(P.eval(l.replace(/^\?\((.*?)\)$/,"$1"),v[m],m)) P.trace(m+";"+x,v,p); });
}
Original issue reported on code.google.com by [email protected]
on 13 Aug 2009 at 10:40
See http://goessner.net/articles/JsonPath/
An example object and expression filters out any book that has a price greater
than 10:
$.store.book[?(@.price < 10)].title
This expression returns 4 titles, when it should return only 2 titles.
The correct expression is:
$.store.book[?(@['price'] < 10)].title
...Running against jsonpath for PHP.
Original issue reported on code.google.com by [email protected]
on 13 Dec 2011 at 9:48
parseInt does not allow negative numbers (NumberStyles.None), this prevents
negative index selectors from working as expected. Personal fix was to use
NumberStyles.AllowLeadingSign
eg. $.data[0].values[-1:].value would return all values in path
$.data[0].values[*].value instead of expected values.
Original issue reported on code.google.com by [email protected]
on 16 Dec 2013 at 10:08
What steps will reproduce the problem?
1. Minify jsonpath.js using MS Build Extensions in Visual Studio 2012
2. Execute a query such as: jsonPath(json, "$.foo[?(@.bar == 'somevalue')]")
What is the expected output? What do you see instead?
Expected Object or false. Instead see the following error in Chrome's
javascript console:
Uncaught SyntaxError: jsonPath: _v is not defined: _v.foo[?(@.bar ==
'somevalue')]
What version of the product are you using? On what operating system?
jsonPath 0.8.0, Windows 8 x64
Please provide any additional information below.
The same query works as expected with the un-minified jsonpath.js
Attached Minified jsonpath.js
Original issue reported on code.google.com by [email protected]
on 26 Apr 2013 at 9:59
Attachments:
What steps will reproduce the problem?
1. Use syntax like: $.['number']
What is the expected output? What do you see instead?
This syntax is not documented, but it is treated as an equivalent to $..number.
What version of the product are you using? On what operating system?
0.8.0
Please provide any additional information below.
replace(/;;;|;;/g, ";..;") in normalize should be the problem
Original issue reported on code.google.com by [email protected]
on 6 Jul 2014 at 3:07
First off, many thanks for creating JsonPath - I'm having great fun with
it! However, I think I may have found an issue. When performing a JsonPath
query on a data structure containing something like
"dataResult" : {
"object" : {
"objectInfo" : {
"className" : "folder",
"typeName" : "Standard Folder",
"id" : "uniqueId"
},
then running a query like $..object.objectInfo[?(@.className=='folder')]
returns no results.
However, running the query $..object[[email protected]=='folder')] does produce
results.
It looks as though the JsonPath code is skipping the
the attached HTML file contains an example, including what I think is a
possible fix, although not being an expert, I've probably got things wrong.
Best regards,
Nick Walker
Original issue reported on code.google.com by [email protected]
on 19 Dec 2007 at 5:05
Attachments:
What steps will reproduce the problem?
Using a script expression [( ... )] or [?( ... )] which contains a 'comma'
doesn't work properly.
Original issue reported on code.google.com by [email protected]
on 16 Sep 2007 at 9:46
I'm having some difficulty to figure out how to use the .net version on
jsonpath. Would you mind add a example taking a string with json and a string
with jsonpath and return a result?
Original issue reported on code.google.com by [email protected]
on 24 Sep 2011 at 6:14
You should avoid closures inside of the jsonPath()-function in the js-version
in order to improve performance.
Example:
(function() {
function doSomething() {};
function jsonPath() {
doSomething();
};
})();
is faster than
function jsonPath() {
function doSomething() {};
doSomething();
}
because those functions have to be created by the js-interpreter on every call
to jsonPath.
Original issue reported on code.google.com by [email protected]
on 31 Oct 2010 at 3:40
protected
class
Original issue reported on code.google.com by [email protected]
on 5 May 2010 at 2:26
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.