Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beyarkay/no-more-json
An API that takes care of JSON parsing so you don't have to
https://github.com/beyarkay/no-more-json
Last synced: about 2 months ago
JSON representation
An API that takes care of JSON parsing so you don't have to
- Host: GitHub
- URL: https://github.com/beyarkay/no-more-json
- Owner: beyarkay
- Created: 2023-07-09T20:21:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-09T20:53:29.000Z (over 1 year ago)
- Last Synced: 2024-08-03T04:08:41.353Z (5 months ago)
- Language: Rust
- Size: 31.3 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
##### Very much a work-in-progess. The idea will remain, but the endpoint will likely change (for the better).
# `no-more-json`
Fed up with JSON APIs? Just want one little value from a massive JSON object? Don't want to
parse the JSON yourself?`no-more-json` does all this for you! Here's an example:
Before 😓:
```
curl https://httpbin.org/ip
{
"origin": "102.222.181.247"
}
```After 🥳:
```
curl 'https://no-more-json.shuttleapp.rs/api?url=https://httpbin.org/ip&q=.origin'
"13.41.13.143"
```Let's break that down:
```
https://no-more-json.shuttleapp.rs/api <-- This is the API for no-more-json
?url=https://httpbin.org/ip <-- This is where you specify the url for your endpoint
&q=.origin <-- This is where you put your jq query to parse the JSON
```
If you don't know about `jq`, check this out: https://jqlang.github.io/jq/So this lets you parse arbitrary JSON blobs and just get back a simple scalar value, without
having to parse the JSON yourself, include a json-parsing library, or trying to include the
`jq` binary into your service.Here's a more complicated example:
Before (using data from wttr.in):
```
curl 'wttr.in/Detroit?format=j1'
{
"current_condition": [
{
"FeelsLikeC": "27", <-- The thing we want
29 other lines we don't want ):
}
],
"nearest_area": [...], <-- 25 lines we don't want ):
"request": [...], <-- 4 lines we don't want
"weather": [...] <-- 1248 lines we don't want!
}
```
The jq query we'd use to extract the feels-like temperature in Celcius is `.current_condition[0].FeelsLikeC`We can use `no-more-json` to make a request to the wttr.in endpoint, extract
the result, and then run the jq query for us on that result, so we just get
back a nice scalar value:```
curl 'https://no-more-json.shuttleapp.rs/api?url=https://wttr.in/Detroit?format=j1&q=.current_condition%5B0%5D.FeelsLikeC'
"27"
```(The URL has been encoded so that the special characters in the jq query (like `[`, `]`) aren't treated specially.)
Isn't that cool!