I want to fetch JSON from an API like https://api.mocki.io/v1/ce5f60e2 , parse it, and just print it out to the console, what crate/methods can I use to achieve this simple task? A little working code snippet with respective packages used will be greatly appreciated.
In this case the console prints : {"city":"Stockholm","name":"Lennart Johansson"}
Well, if you pay attention to all the errors, the actual problem is the other error that you probably have
error: cannot find derive macro `Deserialize` in this scope
--> src/main.rs:1:17
|
1 | #[derive(Debug, Deserialize)]
| ^^^^^^^^^^^
This can be made working by adding the missing use statement:
use serde::Deserialize;
I’m just guessing here. Sorry if I’m guessing incorrectly, and the other error is completely unrelated. In any case, you must have copied something incorrectly since Alice’s code does compile without problems.