Skip to content

Commit

Permalink
getjson: fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lasers committed Dec 24, 2024
1 parent f747ec7 commit da046a3
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions py3status/modules/getjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,28 @@
Examples:
```
# straightforward key replacement
url = 'http://ip-api.com/json'
format = '{lat}, {lon}'
getjson {
url = "https://ifconfig.co/json"
format = "{latitude}, {longitude}"
}
# access child objects
url = 'https://api.icndb.com/jokes/random'
format = '{value-joke}'
getjson {
url = 'https://api.icndb.com/jokes/random'
format = '{value-joke}'
}
# access title from 0th element of articles list
url = 'https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey={KEY}'
format = '{articles-0-title}'
getjson {
url = 'https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey={KEY}'
format = '{articles-0-title}'
}
# access if top-level object is a list
url = 'https://jsonplaceholder.typicode.com/posts/1/comments'
format = '{0-name}'
getjson {
url = 'https://jsonplaceholder.typicode.com/posts/1/comments'
format = '{0-name}'
}
```
@author vicyap
Expand Down

0 comments on commit da046a3

Please sign in to comment.