Skip to content

vamitrou/jpath-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Mitrousis, Vasileios (AMOS SE)Mitrousis, Vasileios (AMOS SE)
Mitrousis, Vasileios (AMOS SE)
and
Mitrousis, Vasileios (AMOS SE)
Jun 2, 2017
8a3db45 · Jun 2, 2017

History

9 Commits
May 3, 2017
May 3, 2017
May 3, 2017
May 3, 2017
Jun 2, 2017

Repository files navigation

jpath-py

XPath-like querying for JSON. Written in python

Example:

d={
    "students": [
        {
            "name": "bob",
            "projects": [
                {
                    "name": "banana"
                },
                {
                    "name": "apple"
                }
            ]
        },
        {
            "name": "alice",
            "projects": [
                {
                    "name": "orange"
                }
            ]
        }
    ]
}

from jpathpy import jpath

# get me the second project's name of the first student
print jpath.get_dict_value(d, "students[0]/projects[1]/name")
>> apple

# get me all the project objects of the first student
print jpath.get_dict_value(d, "students[0]/projects/*")
>> [{'name': 'banana'}, {'name': 'apple'}]

# get me all the project names of all the students
print jpath.get_dict_value(d, "students/*/projects/*/name")
>> [['banana', 'apple'], ['orange']]

About

XPath-like querying for JSON. Written in python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages