-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reddit Comments #1
Comments
Is it not possible to make use of omitempty? |
Nope, I tried here. The problem is that the empty "replies" should be an |
You just need to type alias []Comment and then implement the Unmarshaller interface. See example here: |
Yep. That'd definitely work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We're currently using a slapped together implementation to fetch comments from reddit.com. I'd like to completely model the whole thing out using static types and just encoding/json.Unmarshal() the whole thing. A lot of the complexity around the type hierarchy needed to parse the JSON can be hidden by struct embedding.
However, the "replies" field on comments either returns a list of objects or empty string if there are none. Sadly, I think this will require some kind of run-time type assertion.
The text was updated successfully, but these errors were encountered: