Closed lewtun closed 3 years ago
Does it work if you apply fastcore's obj2dict
to issues
before you serialize it?
thanks @jph00 - this indeed works!
for reference this is what i used:
import json
from ghapi.all import GhApi
from fastcore.xtras import obj2dict
api = GhApi()
issues = api.issues.list_for_repo("huggingface", "transformers", page=1, per_page=5, state="all")
issues = [obj2dict(issue) for issue in issues]
# try to write the first issue
with open("issues.jsonl", "w") as f:
json.dump(issues[0], f)
this should be in the readme, its pretty basic core functionality.
Description of the problem
Hello Jeremy and Hamel,
I'm trying to use
ghapi
to fetch issues from a GitHub repo and then dump them to disk as ajsonl
file, where each line is an issue.The problem I'm running into is that the result from
GhAPI.issues.list_for_repo
containsfastcore
's specialL
type which appears to not be JSON serialisable. As a result I'm getting the following error:TypeError: Object of type L is not JSON serializable
Is there a way to make
L
play nice with JSON?Steps to reproduce
Expected result
I can write GitHub issues to disk in JSON format.
Actual result
Here's the stack trace
Versions
ghapi
: v0.1.16