Skip to content
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

Exception in parsing JSON in comments() #216

Closed
tocttou opened this issue Jan 12, 2018 · 3 comments
Closed

Exception in parsing JSON in comments() #216

tocttou opened this issue Jan 12, 2018 · 3 comments
Labels
Milestone

Comments

@tocttou
Copy link

tocttou commented Jan 12, 2018

Error: Exception in thread "main" com.squareup.moshi.JsonDataException: Expected one of [public, private, restricted, gold_restricted, archived] but was user at path $.data.children[7].data.subreddit_type

Happens "most of the times" in the following code:

        val comments = reddit.subreddit("all").comments().limit(50).build().iterator()
        for (i in 0..9) {
            TimeUnit.SECONDS.sleep(1)
            println(comments.next()[1].author)
        }
@mattbdean mattbdean added the bug label Jan 12, 2018
@mattbdean mattbdean added this to the v1.1.0 milestone Jan 12, 2018
@mattbdean
Copy link
Owner

This only happens when comenting on a user subreddit (see here for an example). Should be an easy fix. All we'd have to do is add an enum value for the user type and handle future unknown values.

I'll fix this when I get home.

Also you don't have to manually sleep your thread, the library handles rate limiting for you.

@mattbdean
Copy link
Owner

Fixed! To use this patch you can either wait until v1.1.0 or use JitPack:

repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    compile 'com.github.mattbdean:JRAW:517837c'
}

@tocttou
Copy link
Author

tocttou commented Jan 13, 2018

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants