{"id":21675,"date":"2021-10-27T19:34:00","date_gmt":"2021-10-27T14:04:00","guid":{"rendered":"https:\/\/tutorial.eyehunts.com\/?p=21675"},"modified":"2023-01-19T18:07:35","modified_gmt":"2023-01-19T12:37:35","slug":"python-convert-string-to-dictionary-example-code","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/","title":{"rendered":"Python convert string to dictionary | Example code"},"content":{"rendered":"\n<p>Using <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-json-loads-function\/\">json.loads()<\/a> or ast.literal_eval() function can convert string to the dictionary in Python. These are inbuilt functions.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example convert string to the dictionary in Python<\/strong><\/h2>\n\n\n\n<p>Simple example code.<\/p>\n\n\n\n<p><strong>Using json.loads()<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import json\n\ns = '{\"X\" : 1, \"Y\" : 2, \"Z\" : 3}'\n\nres = json.loads(s)\n\nprint(res)\nprint(type(res))<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"337\" height=\"136\" src=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-string-to-dictionary.jpg?resize=337%2C136&#038;ssl=1\" alt=\"Python convert string to dictionary\" class=\"wp-image-21689\"\/><\/figure><\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using ast.literal_eval()<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import ast\n\ns = '{\"X\" : 1, \"Y\" : 2, \"Z\" : 3}'\n\nres = ast.literal_eval(s)\n\nprint(res)\n\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: {&#8216;X&#8217;: 1, &#8216;Y&#8217;: 2, &#8216;Z&#8217;: 3}<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>How to convert a String representation of a Dictionary to a dictionary?<\/strong><\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use the built-in <a href=\"https:\/\/docs.python.org\/library\/ast.html#ast.literal_eval\"><code>ast.literal_eval<\/code><\/a>: <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-import-module-library-package-file-system\/\">import <\/a>ast <a href=\"https:\/\/tutorial.eyehunts.com\/python\/types-of-modules-in-python-basics\/\">module <\/a>for it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import ast\n\nstr1 = \"{'muffin' : 'lolz', 'foo' : 'kitty'}\"\nres = ast.literal_eval(str1)\n\nprint(res)\nprint(type)\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n\n<p>{&#8216;muffin&#8217;: &#8216;lolz&#8217;, &#8216;foo&#8217;: &#8216;kitty&#8217;}<br><\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Do comment if you have any doubts or suggestions on this Python convert topic.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note:<\/strong> IDE:&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.jetbrains.com\/pycharm\/\" target=\"_blank\">PyCharm<\/a>&nbsp;2021.3.3 (Community Edition)<\/p><p>Windows 10<\/p><p><strong>Python 3.10.1<\/strong><\/p><p>All<strong>&nbsp;Python Examples&nbsp;are in&nbsp;Python&nbsp;3<\/strong>, so Maybe its different from python 2 or upgraded versions.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Using json.loads() or ast.literal_eval() function can convert string to the dictionary in Python. These are inbuilt functions. Example convert string to the dictionary in Python Simple example code. Using json.loads() Output: Using ast.literal_eval() Output: {&#8216;X&#8217;: 1, &#8216;Y&#8217;: 2, &#8216;Z&#8217;: 3} How to convert a String representation of a Dictionary to a dictionary? Answer: Use the&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Python convert string to dictionary | Example code<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[30],"tags":[175,101,98],"post_series":[],"class_list":["post-21675","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-convert","tag-python-dictionary","tag-python-string"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python convert string to dictionary | Example code<\/title>\n<meta name=\"description\" content=\"Using json.loads() or ast.literal_eval() function can convert string to dictionary in Python. This are inbuilt functions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python convert string to dictionary | Example code\" \/>\n<meta property=\"og:description\" content=\"Using json.loads() or ast.literal_eval() function can convert string to dictionary in Python. This are inbuilt functions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-27T14:04:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-19T12:37:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-string-to-dictionary.jpg\" \/>\n<meta name=\"author\" content=\"Rohit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rohit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/\",\"name\":\"Python convert string to dictionary | Example code\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-string-to-dictionary.jpg\",\"datePublished\":\"2021-10-27T14:04:00+00:00\",\"dateModified\":\"2023-01-19T12:37:35+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"Using json.loads() or ast.literal_eval() function can convert string to dictionary in Python. This are inbuilt functions.\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-string-to-dictionary.jpg?fit=337%2C136&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-string-to-dictionary.jpg?fit=337%2C136&ssl=1\",\"width\":337,\"height\":136},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python convert string to dictionary | Example code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\",\"url\":\"https:\/\/tutorial.eyehunts.com\/\",\"name\":\"Tutorial\",\"description\":\"By EyeHunts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\",\"name\":\"Rohit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"contentUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"caption\":\"Rohit\"},\"description\":\"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.\",\"url\":\"https:\/\/tutorial.eyehunts.com\/author\/rohit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python convert string to dictionary | Example code","description":"Using json.loads() or ast.literal_eval() function can convert string to dictionary in Python. This are inbuilt functions.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/","og_locale":"en_US","og_type":"article","og_title":"Python convert string to dictionary | Example code","og_description":"Using json.loads() or ast.literal_eval() function can convert string to dictionary in Python. This are inbuilt functions.","og_url":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/","og_site_name":"Tutorial","article_published_time":"2021-10-27T14:04:00+00:00","article_modified_time":"2023-01-19T12:37:35+00:00","og_image":[{"url":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-string-to-dictionary.jpg","type":"","width":"","height":""}],"author":"Rohit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rohit","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/","url":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/","name":"Python convert string to dictionary | Example code","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/#primaryimage"},"thumbnailUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-string-to-dictionary.jpg","datePublished":"2021-10-27T14:04:00+00:00","dateModified":"2023-01-19T12:37:35+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"Using json.loads() or ast.literal_eval() function can convert string to dictionary in Python. This are inbuilt functions.","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/#primaryimage","url":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-string-to-dictionary.jpg?fit=337%2C136&ssl=1","contentUrl":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-string-to-dictionary.jpg?fit=337%2C136&ssl=1","width":337,"height":136},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-string-to-dictionary-example-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"Python convert string to dictionary | Example code"}]},{"@type":"WebSite","@id":"https:\/\/tutorial.eyehunts.com\/#website","url":"https:\/\/tutorial.eyehunts.com\/","name":"Tutorial","description":"By EyeHunts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1","name":"Rohit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/","url":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","contentUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","caption":"Rohit"},"description":"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.","url":"https:\/\/tutorial.eyehunts.com\/author\/rohit\/"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":21249,"url":"https:\/\/tutorial.eyehunts.com\/python\/convert-python-string-to-json-example-code\/","url_meta":{"origin":21675,"position":0},"title":"Convert Python string to JSON | Example code","author":"Rohit","date":"October 19, 2021","format":false,"excerpt":"Use json.loads() method to convert JSON string to JSON in Python. This method will convert JSON string into dict. json.loads(string) Python string to JSON example Simple example code. Import json module then uses the loadS() method. This method accepts a valid json string and returns a dictionary. import json #\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python string to JSON","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-string-to-JSON.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":35502,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-json-string-to-dict\/","url_meta":{"origin":21675,"position":1},"title":"Python JSON string to dict","author":"Rohit","date":"January 17, 2023","format":false,"excerpt":"Use Python's built-in JSON load() function to convert JSON string to dict. This function takes a json object as input and converts it to the dictionary. Python JSON string to dict example A simple example code passes the json object to the load function. import json jsonData = '{\"firstName\": \"Edward\",\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/01\/Python-JSON-string-to-dict.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/01\/Python-JSON-string-to-dict.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/01\/Python-JSON-string-to-dict.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":34542,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-json-loads-function\/","url_meta":{"origin":21675,"position":2},"title":"Python JSON loads() | Function","author":"Rohit","date":"November 30, 2022","format":false,"excerpt":"Python JSON loads() Function is used to parse a valid JSON string and convert it into a Dictionary. it can read JSON data from text, JSON, or binary files. json.loads(s) Python JSON loads() Simple example code. import json # JSON string: x = \"\"\"{ \"Name\": \"John king\", \"Contact Number\": 1234567890,\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/11\/Python-JSON-loads-Function.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/11\/Python-JSON-loads-Function.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/11\/Python-JSON-loads-Function.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":21321,"url":"https:\/\/tutorial.eyehunts.com\/python\/import-json-in-python\/","url_meta":{"origin":21675,"position":3},"title":"Import JSON in Python","author":"Rohit","date":"October 21, 2021","format":false,"excerpt":"Python has a built-in json module, which can be used to work with JSON data. See below the syntax of Import the json module: JSON can store Lists, bools, numbers, tuples, and dictionaries. import json The JSON module is mainly used to convert the python dictionary above into a JSON\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Import-JSON-in-Python.gif?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Import-JSON-in-Python.gif?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Import-JSON-in-Python.gif?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Import-JSON-in-Python.gif?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":21311,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-json-to-string-example-code\/","url_meta":{"origin":21675,"position":4},"title":"Python JSON to string | Example code","author":"Rohit","date":"October 20, 2021","format":false,"excerpt":"Using json.dumps() can convert JSON to string in Python. It would always produce a valid JSON string (assuming everything inside the object is serializable). Python JSON to string example Simple example code dumps() would convert None into null making a valid JSON string that can be loaded: import json json_obj\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Convert-Json-to-String-with-API.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Convert-Json-to-String-with-API.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Convert-Json-to-String-with-API.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":35467,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-read-json-file-into-dict\/","url_meta":{"origin":21675,"position":5},"title":"Python read JSON file into dict","author":"Rohit","date":"January 13, 2023","format":false,"excerpt":"Use the json module loads method to read JSON files into dict in Python. JSON loads create a new dictionary with the key-value pairs of the JSON string and it returns this new dictionary. json.loads(data_JSON) Python read JSON files into dict example Simple example code load JSON from a File\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/01\/Python-read-JSON-file-into-dict.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/01\/Python-read-JSON-file-into-dict.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/01\/Python-read-JSON-file-into-dict.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/01\/Python-read-JSON-file-into-dict.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/01\/Python-read-JSON-file-into-dict.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/21675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/comments?post=21675"}],"version-history":[{"count":1,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/21675\/revisions"}],"predecessor-version":[{"id":35614,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/21675\/revisions\/35614"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=21675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=21675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=21675"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=21675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}