Not having much experience with Python, I quickly realized I needed something to query json blobs. I found this library, but cannot get anything to work, except the simplest of examples (which don't actually help me since basic json support already has).
I have a valid json schema (with elements removed)
{
"schemaVersion": "caas-api-v2",
"endpoints": [{
"type": "version",
"url": "/version",
"description": "Returns version string"
}, {
"type": "profile",
"url": "/api/v2/profile",
"description": "Returns information about the profile"
}, {
"type": "create-something",
"url": "/api/v2/something",
"description": "Create something POST endpoint"
}]
}
1) when I try
tree = Tree(myData['endpoints']) # where myData contains the whole schema above
path = tree.execute("$endpoints")
I get back the endpoints object. Great...
2) when I try
path = tree.execute("$endpoints")[1]
I get back the 2nd object in endpoints. Great...
3) when I try
path = tree.execute("$endpoints[@.type is 'version']")
I get back <generator object exeSelector at 0x00000000030A9630>
Is this an error that the object can't be found? If so why?
I expected to get the entire object that contains an element whose type key is set to the value version. What am I missing?
thanks for any help... - Nicholas