Unable to create Dictionary in Python. Dealing with Invalid JSON Files

python

#1

Good day everyone. Please help me in creating dictionary out from this invalid json. I used json.loads() and even tried ast.literal_eval() but it failed. The json data below is from the text files that I’m working with. Big thanks in advance.

{‘id_str’: ‘707448633264893952’, ‘contributors’: None, ‘filter_level’: ‘low’, ‘retweet_count’: 0, ‘created_at’: ‘Wed Mar 09 06:11:12 +0000 2016’, ‘source’: ‘Twitter for iPhone’, ‘timestamp_ms’: ‘1457503872587’, ‘in_reply_to_status_id_str’: None, ‘is_quote_status’: False, ‘text’: ‘ให้ยอมลาร้ากกนั้นชั้นทนไม่ไหว’, ‘in_reply_to_status_id’: None, ‘in_reply_to_user_id_str’: None, ‘user’: {‘description’: None, ‘id_str’: ‘1662006936’, ‘name’: ‘공허해’, ‘profile_background_color’: ‘F5ABB5’, ‘contributors_enabled’: False, ‘profile_sidebar_border_color’: ‘FFFFFF’, ‘notifications’: None, ‘listed_count’: 3, ‘follow_request_sent’: None, ‘protected’: False, ‘location’: None, ‘default_profile’: False, ‘profile_sidebar_fill_color’: ‘E5507E’, ‘profile_text_color’: ‘362720’, ‘verified’: False, ‘statuses_count’: 61406, ‘profile_background_image_url_https’: ‘https://pbs.twimg.com/profile_background_images/516822708542111744/mt6EAO-x.png’, ‘followers_count’: 265, ‘is_translator’: False, ‘geo_enabled’: True, ‘profile_background_tile’: True, ‘utc_offset’: 25200, ‘favourites_count’: 6088, ‘default_profile_image’: False, ‘following’: None, ‘profile_image_url_https’: ‘https://pbs.twimg.com/profile_images/707272353294655488/A3iBg8yv_normal.jpg’, ‘profile_banner_url’: ‘https://pbs.twimg.com/profile_banners/1662006936/1457435864’, ‘lang’: ‘en’, ‘id’: 1662006936, ‘profile_image_url’: ‘http://pbs.twimg.com/profile_images/707272353294655488/A3iBg8yv_normal.jpg’, ‘url’: ‘https://www.instagram.com/pldoy/’, ‘time_zone’: ‘Bangkok’, ‘created_at’: ‘Sun Aug 11 08:41:46 +0000 2013’, ‘profile_background_image_url’: ‘http://pbs.twimg.com/profile_background_images/516822708542111744/mt6EAO-x.png’, ‘profile_link_color’: ‘F5ABB5’, ‘screen_name’: ‘_pgems’, ‘profile_use_background_image’: True, ‘friends_count’: 30}, ‘retweeted’: False, ‘in_reply_to_user_id’: None, ‘favorited’: False, ‘favorite_count’: 0, ‘coordinates’: None, ‘lang’: ‘th’, ‘id’: 707448633264893952, ‘geo’: None, ‘place’: {‘place_type’: ‘admin’, ‘id’: ‘017b52517f71306e’, ‘name’: ‘Amphoe Mueang Pathum Thani’, ‘url’: ‘https://api.twitter.com/1.1/geo/id/017b52517f71306e.json’, ‘bounding_box’: {‘type’: ‘Polygon’, ‘coordinates’: [[[100.452728, 13.936413], [100.452728, 14.060812], [100.607423, 14.060812], [100.607423, 13.936413]]]}, ‘country_code’: ‘TH’, ‘country’: ‘ประเทศไทย’, ‘full_name’: ‘Amphoe Mueang Pathum Thani, Pathum Thani Province’, ‘attributes’: {}}, ‘in_reply_to_screen_name’: None, ‘truncated’: False, ‘entities’: {‘symbols’: [], ‘user_mentions’: [], ‘urls’: [], ‘hashtags’: []}}