Intermittent JSON parsing exceptions
kikkia opened this issue · 2 comments
kikkia commented
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 commented
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 commented
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