LogoopenSUSE Build Service > Projects
Sign Up | Log In

Extract Elements From A JSON Document

JMESPath (pronounced "jaymz path") allows you to declaratively specify how to extract elements from a JSON document.

For example, given this document:

{"foo": {"bar": "baz"}}

The jmespath expression foo.bar will return "baz".

JMESPath also supports:

Referencing elements in a list. Given the data:

{"foo": {"bar": ["one", "two"]}}

The expression: foo.bar[0] will return "one". You can also reference all the items in a list using the * syntax:

{"foo": {"bar": [{"name": "one"}, {"name": "two"}]}}

The expression: foo.bar[*].name will return ["one", "two"]. Negative indexing is also supported (-1 refers to the last element in the list). Given the data above, the expression foo.bar[-1].name will return ["two"].

The * can also be used for hash types:

{"foo": {"bar": {"name": "one"}, "baz": {"name": "two"}}}

The expression: foo.*.name will return ["one", "two"].

Source Files (show merged sources derived from linked package)

Filename Size Changed Actions
jmespath-0.9.3.tar.gz 22.4 KB 12 months ago Download File
python-jmespath.changes 4.49 KB 2 months ago Download File
python-jmespath.spec 3.02 KB 2 months ago Download File

Comments for home:inescid:python (0)

Login required, please login or signup in order to comment