dunossauro / dunossauro/live-de-python

[SUGESTÃO] Live de JMESPath

Open
#520 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.3k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

Muito tempo atrás assisti ao vídeo chamado [Selenium com Python palestra - Conhecendo XPATH com Renne Rocha](https://www.youtube.com/watch?v=vuLNc2yCNYk), e com ele conheci o XPATH pela primeira vez, coisa mais linda que que me fez largar o [bs4](https://pypi.org/project/beautifulsoup4/) no mesmo instante, e com ele também me foi apresentado a biblioteca [parsel](https://pypi.org/project/parsel/), biblioteca excelente esta que não só dá suporte ao XPATH e CSS Selector, como também ao assunto da vez: **JMESPath** - 'JamesPath'.

No entanto diferente de XPATH e CSS Selector, o alvo de expressões JMESPath são formatos JSON.

ListComps gigantes? não mais.

## Demonstração
JSON:
```json
[
{"name": "John", "age": 32, "address": {"state": "CA"}},
{"name": "James", "age": 30, "address": {"state": "CA"}},
{"name": "Jacob", "age": 46, "address": {"state": "CA"}},
{"name": "Alex", "age": 42, "address": {"state": "CA"}}
]
```

Python:
```python
old_people = [
person["name"]
for person in data
if person['age'] > 30 and person['address']['state'] == 'CA'
]
```

JMESPath:
```
[?age > `30` && address.state == 'CA'].name
```

## Materiais
- Testador: https://jmespath.org/
- Especificações: https://jmespath.org/specification.html
- Tutoriais práticos: https://jmespath.org/tutorial.html

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.