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

Intermittent JSON parsing exceptions #303

Open
kikkia opened this issue Jun 2, 2020 · 2 comments
Open

Intermittent JSON parsing exceptions #303

kikkia opened this issue Jun 2, 2020 · 2 comments

Comments

@kikkia
Copy link

kikkia commented Jun 2, 2020

I am hitting intermittent errors that look like they are coming from when the json responses are being parsed. Wondering if anyone has seen this before:

2020-06-02 22:15:56.509787 vinny-jar: Error thrown when getting reddit post
Expected an int but was BEGIN_OBJECT at path $.data.accounts_active
com.squareup.moshi.JsonDataException: Expected an int but was BEGIN_OBJECT at path $.data.accounts_active
    at com.squareup.moshi.JsonUtf8Reader.nextInt(JsonUtf8Reader.java:890)
    at com.squareup.moshi.StandardJsonAdapters$7.fromJson(StandardJsonAdapters.java:173)
    at com.squareup.moshi.StandardJsonAdapters$7.fromJson(StandardJsonAdapters.java:171)
    at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:137)
    at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:137)
    at net.dean.jraw.models.AutoValue_Subreddit$MoshiJsonAdapter.fromJson(AutoValue_Subreddit.java:134)
    at net.dean.jraw.models.AutoValue_Subreddit$MoshiJsonAdapter.fromJson(AutoValue_Subreddit.java:29)
    at net.dean.jraw.models.internal.AutoValue_RedditModelEnvelope$MoshiJsonAdapter.fromJson(AutoValue_RedditModelEnvelope.java:38)
    at net.dean.jraw.models.internal.AutoValue_RedditModelEnvelope$MoshiJsonAdapter.fromJson(AutoValue_RedditModelEnvelope.java:17)
    at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:137)
    at net.dean.jraw.databind.RedditModelAdapterFactory$StaticAdapter.fromJson(RedditModelAdapterFactory.kt:112)
    at com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:41)
    at net.dean.jraw.http.HttpResponse.deserializeWith(HttpResponse.kt:49)
    at net.dean.jraw.references.SubredditReference.about(SubredditReference.kt:254)
@gharris1727
Copy link

I've got the same problem but on a different resource:

com.squareup.moshi.JsonDataException: Expected an int but was NULL at path $.subreddits[0].active_user_count

The record coming back from the request is indeed null:

{"subreddits": [{
  "active_user_count": null,
  "icon_img": "https://a.thumbs.redditmedia.com/QKbhVv1hqixLa2XAcPS3M8gge_nrU7YWOvUjAxOktz4.png",
  "key_color": "#94e044",
  "name": "trees",
  "subscriber_count": 1740677,
  "is_chat_post_feature_enabled": false,
  "allow_chat_post_creation": false,
  "allow_images": true}
]}

@andehr
Copy link

andehr commented Aug 30, 2021

I guess this becomes an increasing problem as JRAW loses support and the Reddit API continues to change. Here's my hack to avoid having to alter and re-build JRAW (essentially intercept the JSON payloads and change the JSON such that JRAW recognises it): #300 (comment)

The comment shows an example of removing oembed elements with null type fields from the JSON before JRAW gets to see the JSON

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

No branches or pull requests

3 participants