Parsing GitHub API

I want to make a CLI releases downloader from GitHub.

But i have two problems:

  • nested JSON
  • i don't know, how much assets are in the release ( i think i can solve it with vectors )

Can you suggest me ways to solve this?

I think i could deal it with running JavaScript, but this is kinda strange if i could do it with native Rust.

serde?

Show your code (structs with derive probably), then we can help.

Sometimes reinventing the wheel may not be worth it (other times, if your use case is simple enough, it may very well be worth it, in which case I'd indeed recommend using ::serde).

So, let's search a bit for what's around:

And then we can go to the rustdoc docs.rs site of each of the top crates, to search for releases (given your use case):

1 Like

I used GraphQL client:

And then used the GraphQL API. It worked great, but might be more than you need for your case?

You essentially use the GitHub API explorer to create a query, then you paste that query into a file in your Rust project, and you use the GraphQL client crate to create a statically typed interface to that query's data.

1 Like

I've written a little client with paging support:

With serde you define deserializable structs for GitHub API's JSON:

2 Likes