python-twitter icon indicating copy to clipboard operation
python-twitter copied to clipboard

Include null and false values in AsJsonString() results.

Open changeling opened this issue 7 years ago • 1 comments

This is a request to include null and false values in AsJsonString() results.

Two User objects to illustrate:

{
  "created_at": "Mon Sep 15 08:46:12 +0000 2014", 
  "default_profile": true, 
  "followers_count": 18, 
  "friends_count": 198, 
  "id": 2810946506, 
  "id_str": "2810946506", 
  "lang": "en", 
  "name": "Abd Kanaan", 
  "profile_background_color": "C0DEED", 
  "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", 
  "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", 
  "profile_banner_url": "https://pbs.twimg.com/profile_banners/2810946506/1410771002", 
  "profile_image_url": "http://pbs.twimg.com/profile_images/511436605404356608/qTFjZwEA_normal.jpeg", 
  "profile_image_url_https": "https://pbs.twimg.com/profile_images/511436605404356608/qTFjZwEA_normal.jpeg", 
  "profile_link_color": "1DA1F2", 
  "profile_sidebar_border_color": "C0DEED", 
  "profile_sidebar_fill_color": "DDEEF6", 
  "profile_text_color": "333333", 
  "profile_use_background_image": true, 
  "screen_name": "captkanaan", 
  "statuses_count": 3
}, 

{
  "created_at": "Wed Apr 23 06:57:53 +0000 2008", 
  "description": "Bylines: @Inc @Entrepreneur @BI_contributors. Opinions My own. Bio and writing inquiries: https://t.co/M9ZaFm2Vz4", 
  "favourites_count": 7399, 
  "followers_count": 115789, 
  "following": true, 
  "friends_count": 87270, 
  "geo_enabled": true, 
  "id": 14486811, 
  "id_str": "14486811", 
  "lang": "en", 
  "listed_count": 2789, 
  "location": "San Francisco, CA", 
  "name": "John Boitnott", 
  "profile_background_color": "8E1C2B", 
  "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", 
  "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", 
  "profile_background_tile": true, 
  "profile_banner_url": "https://pbs.twimg.com/profile_banners/14486811/1445441600", 
  "profile_image_url": "http://pbs.twimg.com/profile_images/924008629698576384/SFeoaYv4_normal.jpg", 
  "profile_image_url_https": "https://pbs.twimg.com/profile_images/924008629698576384/SFeoaYv4_normal.jpg", 
  "profile_link_color": "19CF86", 
  "profile_sidebar_border_color": "87BC44", 
  "profile_sidebar_fill_color": "E0FF92", 
  "profile_text_color": "000000", 
  "profile_use_background_image": true, 
  "screen_name": "jboitnott", 
  "statuses_count": 33595, 
  "url": "https://t.co/UwrWWzKcnI", 
  "verified": true
}, 

changeling avatar Aug 23 '18 21:08 changeling

To clarify, dumping __dict__, and ignoring _json, yields all values, including some that are absent entirely fromAsJsonString(), while AsJsonString() does not.

One of the above-mentioned Users as represented in __dict__, sans _json:

{
      "contributors_enabled": false, 
      "created_at": "Wed Apr 23 06:57:53 +0000 2008", 
      "default_profile": false, 
      "default_profile_image": false, 
      "description": "Bylines: @Inc @Entrepreneur @BI_contributors. Opinions My own. Bio and writing inquiries: https://t.co/M9ZaFm2Vz4", 
      "email": null, 
      "favourites_count": 7390, 
      "followers_count": 115821, 
      "following": true, 
      "friends_count": 87297, 
      "geo_enabled": true, 
      "id": 14486811, 
      "id_str": "14486811", 
      "lang": "en", 
      "listed_count": 2789, 
      "location": "San Francisco, CA", 
      "name": "John Boitnott", 
      "notifications": false, 
      "profile_background_color": "8E1C2B", 
      "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", 
      "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", 
      "profile_background_tile": true, 
      "profile_banner_url": "https://pbs.twimg.com/profile_banners/14486811/1445441600", 
      "profile_image_url": "http://pbs.twimg.com/profile_images/924008629698576384/SFeoaYv4_normal.jpg", 
      "profile_image_url_https": "https://pbs.twimg.com/profile_images/924008629698576384/SFeoaYv4_normal.jpg", 
      "profile_link_color": "19CF86", 
      "profile_sidebar_border_color": "87BC44", 
      "profile_sidebar_fill_color": "E0FF92", 
      "profile_text_color": "000000", 
      "profile_use_background_image": true, 
      "protected": false, 
      "screen_name": "jboitnott", 
      "status": null, 
      "statuses_count": 33575, 
      "time_zone": null, 
      "url": "https://t.co/UwrWWzKcnI", 
      "utc_offset": null, 
      "verified": true, 
      "withheld_in_countries": null, 
      "withheld_scope": null
    }, 

changeling avatar Aug 23 '18 21:08 changeling