Some submissions fail to parse because fields can be null
I got hit by:
*** Exception: JSONParseError "runAction: Error parsing JSON - Error in $.children[73]['all_awardings'][0]['days_of_premium']: parsing Int failed, expected Number, but encountered Null"
Turns out that various fields such as days_of_premium
can be null
, see e.g.
http://count.reddit-stream.com/api_info/comment.all_awardings.N
and the concrete example I encountered when trying to parse /r/haskell
submissions:
{
"kind": "t3",
"data": {
"approved_at_utc": null,
"subreddit": "haskell",
"selftext": "",
"author_fullname": "t2_svn83",
"saved": false,
"mod_reason_title": null,
"gilded": 0,
"clicked": false,
"title": "Teaching GHC how to play Minesweeper",
"link_flair_richtext": [],
"subreddit_name_prefixed": "r/haskell",
"hidden": false,
"pwls": 6,
"link_flair_css_class": "",
"downs": 0,
"top_awarded_type": null,
"hide_score": false,
"name": "t3_z86rwf",
"quarantine": false,
"link_flair_text_color": "light",
"upvote_ratio": 1,
"author_flair_background_color": null,
"subreddit_type": "public",
"ups": 39,
"total_awards_received": 1,
"media_embed": {},
"author_flair_template_id": null,
"is_original_content": false,
"user_reports": [],
"secure_media": null,
"is_reddit_media_domain": false,
"is_meta": false,
"category": null,
"secure_media_embed": {},
"link_flair_text": "blog",
"can_mod_post": false,
"score": 39,
"approved_by": null,
"is_created_from_ads_ui": false,
"author_premium": false,
"thumbnail": "",
"edited": false,
"author_flair_css_class": null,
"author_flair_richtext": [],
"gildings": {
"gid_1": 1
},
"content_categories": null,
"is_self": false,
"mod_note": null,
"created": 1669757324,
"link_flair_type": "text",
"wls": 6,
"removed_by_category": null,
"banned_by": null,
"author_flair_type": "text",
"domain": "github.com",
"allow_live_comments": false,
"selftext_html": null,
"likes": null,
"suggested_sort": null,
"banned_at_utc": null,
"url_overridden_by_dest": "https://github.com/effectfully-ou/sketches/tree/master/mineunifier",
"view_count": null,
"archived": false,
"no_follow": false,
"is_crosspostable": false,
"pinned": false,
"over_18": false,
"all_awardings": [
{
"giver_coin_reward": null,
"subreddit_id": null,
"is_new": false,
"days_of_drip_extension": null,
"coin_price": 100,
"id": "gid_1",
"penny_donate": null,
"award_sub_type": "GLOBAL",
"coin_reward": 0,
"icon_url": "https://www.redditstatic.com/gold/awards/icon/silver_512.png",
"days_of_premium": null,
"tiers_by_required_awardings": null,
"resized_icons": [
{
"url": "https://www.redditstatic.com/gold/awards/icon/silver_16.png",
"width": 16,
"height": 16
},