Questions tagged [objectpath]

ObjectPath can be considered a full-featured expression language. ObjectPath is a query language similar to XPath or JSONPath, but much more powerful thanks to embedded arithmetic calculations, comparison mechanisms and built-in functions. This makes the language more like SQL in terms of expressiveness, but it works over JSON documents rather than relations.

ObjectPath makes it easy to find data in big nested JSON documents. It borrows the best parts from E4X, JSONPath, XPath and SQL. ObjectPath is to JSON documents what XPath is to XML.

please visit this link to know more about object-path

15 questions
4
votes
2 answers

ObjectPath: trouble with "in" operator

I am learning ObjectPath for python and have found out, e.g., how to do an exact match on an attribute: >>> import objectpath >>> >>> tree = objectpath.Tree({'doc': {'title': 'Purple is Best Color'}}) >>> >>> tree.execute('$..*[@.title is "Purple is…
norman
  • 5,128
  • 13
  • 44
  • 75
3
votes
1 answer

ModuleNotFoundError: No module named 'objectpath' while the package is installed

I'm using python 3.7.1 (on windows 10) for the first time and i want to import objectpath I have installed the package successfully with pip using: pip install objectpath Requirement already satisfied: objectpath in…
rachid rachid
  • 187
  • 12
3
votes
1 answer

objectpath json query to get array values in python

I've got some JSON like the following: { "books": [ { "name": "Matthew" }, { "name": "Mark", "sections": [ { "reference": "1:1-1:8", "tags": [ "a", …
SupaGu
  • 579
  • 6
  • 18
2
votes
1 answer

Filter JSON object based on children keys

I am trying to find a procedural way of applying the following filter. Given the following object, how can I get all top-level keys that contain child c2? { "a1" : { "b" : { "c1": {}, "c2": {} } }, "a2" : { "b" : { …
Hubert Grzeskowiak
  • 15,137
  • 5
  • 57
  • 74
2
votes
2 answers

query on nested python objects

I have some objects structure created with YAML. Inside YAML many tags are used. So the document contains not only builtin types but also some objects created from registered constructors. I need to check them by some patterns. So far I've tried…
Ev_genus
  • 135
  • 11
1
vote
1 answer

Get names of keys in objectpath

How would I get the names of the keys, for example [800, 801] (the key names are unknown) with objectpath. It is easy in jmespath: keys(@). "groups": { "800": { "short_name": "22", "oname": "11", "group": 8, "title":…
abruski
  • 851
  • 3
  • 10
  • 27
1
vote
3 answers

extract urls from json file without data name using python

i have json file that containd the metadata of 900 articles and i want to extract the Urls from it. my file start like this [ { "title": "The histologic phenotypes of …", "authors": [ { "name": "JE Armes" }, …
1
vote
3 answers

How can one create a python dictionary (key : value) from select objects in a JSON file with multiple JSON lines

I have a file with multiple JSON lines as shown below. {"status str":null,"id":563221, "filter":"low","text" : "Grass is green"} {"status str":null,"id":612835, "filter":"high","text" : "Textual blue"} My desired output should show only the ID…
Biyinzika
  • 75
  • 9
1
vote
1 answer

How can I navigate a JSON file that has an array in it to select the values using Objectpath in python?

I have multiple JSON files to cover and can't seem to access the specific text(distracter) below. This is an example of a line in the file :…
Biyinzika
  • 75
  • 9
1
vote
1 answer

I am trying to use python's objectpath to pick specific values out of a multi-level json/dictionary, but can't get to my desired target format

Imagine I hit an API and it returns a multi-level json blob. I want to then pull specific values out of that blob and then upload it to a database, so I need to flatten it. Basically I want to move from something like this: d1 = {'results': [ …
kahsm
  • 67
  • 7
0
votes
1 answer

Conda ObjectPath Installation is not working

I tried installing objectpath in Conda promt using conda install -c auto objectpath but this does not install saying packages not found. I used the code in the https://anaconda.org/auto/objectpath. I have a doubt whether there is a new…
Jacky
  • 41
  • 1
  • 9
0
votes
1 answer

Python - Parse complex JSON with objectpath

i need parse terraform file, write in JSON format. I have to extract two data, resource and id, this is example file: { "version": 1, "serial": 1, "modules": [ { "path": [ "root" ], …
stecog
  • 2,202
  • 4
  • 30
  • 50
0
votes
1 answer

Python3 -- objectpath ...broken?

After hours of unsuccessfully trying to use objectpath in a Python3-script, I made the following simple experiment: >>> from objectpath import * >>> tree=Tree({"a":1}) >>> tree.execute("$.a") Expected output: 1 Success with python (2) ~$…
reinhardS
  • 3
  • 2
0
votes
1 answer

How can someone create a python key:value dictionary from a nested array in a JSON file with multiple lines in python?

I have a JSON file with values in [] brackets as shown. I am trying to create a [key:value] dictionary that shows the [id_value : text_value.] {"id":6127465, "users":{"name":[{"dr_info":[28,37],"text":"trees"}],"favorites":[]}} {"id":9285628,…
Biyinzika
  • 75
  • 9
-1
votes
1 answer

How do I return an upper field in a JSON with python?

So, I need some help returning an ID having found a certain string. My JSON looks something like this: { "id": "id1" "field1": { "subfield1": { "subrield2": { "subfield3": { "subfield4": [ "string1", "string2", "string3" …
Razvan
  • 1