Convert all nested dictionary keys to lowercase python. html>ys


Step-by-step approach: Convert all dictionary keys to lowercase in python; Python - regex , remove all single characters,replace all single chars,char; Convert all string values in a list to integers using python; Loop through string characters in Python; String characters to list items using python; Get first N characters from a string in Python Apr 26, 2023 · Given a flattened dictionary, the task is to convert that dictionary into a nested dictionary where keys are needed to be split at '_' considering where nested dictionary will be started. defaultdict to make your life easier. Of course, if you can be certain that only the content key is important and always present, you could just create entirely new dictionaries with just that Jun 14, 2014 · A convenience function to do this might look something like: def as_dict (config): """ Converts a ConfigParser object into a dictionary. In a nested dictionary, the values mapped to keys are also dictionaries. If you do not want to use dict comprehension then you can use the below code to convert dictionary keys to lowercase format. Jun 10, 2023 · The addition of elements to a nested Dictionary can be done in multiple ways. Otherwise, you’ll get weird indexing and possibly a dictionary for the value of a single cell. literal_eval) this will convert str to dict. This is useful for standardizing and comparing strings without considering case differences. Initialize a list named ‘keys’ containing the desired keys for the output dictionary. If a value is itself a dictionary, the function is called recursively to convert the keys in the nested dictionary as well. One way to add a dictionary in the Nested dictionary is to add values one be one, Nested_dict [dict] [key] = ‘value’. Step-by-step approach : The function checks if the input dd is a dictionary. . I can convert an object to a dictionary by using the __dict__ property, no problem. Method #1: Using Naive Approach. # Sample dictionary. Here are some examples: Method 1: Using a for loop to iterate over the dictionary and convert the keys and values to lowercase. lower(), [x. def convert_case(str_camelcase): # This function takes in a string in camelCase and converts it to snake_case str_snake_case = "" for ele in Jan 13, 2023 · 10 different ways to Convert a Python List to a Dictionary. At last, call numpy. Otherwise, it creates a nested dictionary at the first key if it doesn’t already exist, and then recursively calls the function with the remaining keys and value. Nov 18, 2021 · For my purpose I would like to convert the nested dictionary into a pandas dataframe of the form: Python Pandas: Convert nested dictionary to dataframe int(v) -- v is a dictionary! this line here, you are trying to convert a dictionary to an integer. Exercise 1: Convert two lists into a dictionary. You’ll also learn how to work with nested dictionaries to convert them to a Pandas DataFrame. Sep 14, 2015 · With this solution, you need to flatten the dictionary, because csv. search() To check if the sequence of one upper case Apr 4, 2023 · Given a nested dictionary, the task is to convert this dictionary into a flattened dictionary where the key is separated by ‘_’ in case of the nested key to be started. Initialize a tuple named ‘test_tuple’ with nested tuples as its elements. For example, tree_dict = 42 leads to a nested dict Aug 8, 2018 · 1. normalize in pandas but values were of str type. Exercise 5: Create a dictionary by extracting the keys from a given dictionary. However, I am running into a lot of errors. Jun 7, 2020 · Pandas: Convert dictionary to dataframe where keys and values are the columns 1 Convert Pandas DataFrame to dictionary where columns are keys and (column-wise) rows are values Feb 13, 2024 · Here is a function that updates nested dictionaries by searching for a specified key no matter how deeply it is nested: def update_nested_dict(d, key, value): for k, v in d. Though str. Nested Dictionaries in Data Analysis. d[k. lower() for x in myDict[k1][k2]]) for k2 in myDict[k1]. But I want to convert all keys and values at all levels into strings. The dictionary consists of data that needs to correspond to case insensitive input, e. abc import Mapping. I have this Python dictionary that needs to be converted to lowercase. Nested Oct 4, 2022 · The keys() method in Python Dictionary, returns a view object that displays a list of all the keys in the dictionary in order of insertion using Python. Jun 10, 2022 · Mapping values and keys from a nested dictionary to columns. Converting two lists of different length to a dictionary. from_dict () method constructs a DataFrame from a dictionary. keys()[0] and dict. The following is an example of how to use the `str. keys only returns the top level keys of the dictionary. keys(): print i for j in d[i]. append(tuple(keys + list(d))) else: result. casefold() as well. Jan 4, 2024 · Creating a nested dictionary in Python can be done in multiple ways. In this article, we will look at two different ways. upper fails in such cases, str. In this example, values in the nested market dictionary are accessed using the get() method. from collections. Function: Jan 9, 2020 · In python, append is only for lists, not dictionaries. return result. items() if k=='key1')) Output. How nested the dictionary will be is variable which makes it a bit complicated. keys() ]) >>> newDict {'mykey': {'mykey2': [u'abc']}} Nov 3, 2016 · This easiest way is to build the dictionary starting from the inside out: tree_dict = {key: tree_dict} With an arbitrary terminal value: result = {k: result} Probably worth pointing out that if the leave has to be some other value than a dict, one can just initialise tree_dict accordingly. Jul 27, 2021 · How to Flatten a Dict in Python Using your Own Recursive Function + Generators. Feb 21, 2024 · With Python 3. Jan 5, 2024 · The `lower ()` method is a string method in Python. To create a new dictionary with the flattened keys it maintains in memory a Python list. It's a collection of dictionaries into one single dictionary. Return a set containing all nested keys. keys(): print j OR. a: dict(zip(k, v)) for a, k, v in zip(. Converting a list of tuples to a dictionary. like @BHISM NARAYAN said: a dictionary is not subscriptable. Here’s an example: original_dict = {'Name': 'Alice', 'AGE': 'TWENTY-FIVE', 'Country': 'USA'} lowercase_dict = {**{k. Jan 22, 2020 · Would like to convert only dictionary keys to UPPERCASE. 5. keys()[0] will give TypeError: 'dict_keys' object is not subscriptable. Feb 17, 2014 · You can use tuple unpacking combined with collections. """ the_dict = {} for section in config. However, I'm having trouble figuring out the best way to convert all the nested objects as well, without having to do each level explicitly. May 3, 2017 · keys() method returns a view object that displays a list of all the keys in the dictionary. Exercise 3: Print the value of key ‘history’ from the below dict. items()} def convert_list(lst): return [convert_value(item) for item in lst] def convert_value(v): if isinstance(v, dict): return convert_dict(v) elif isinstance(v, list): return convert_list(v) # more elifs. Given a dictionary ,the task is to convert keys of dictionary to a list. 3. To copy it over: def nested_set(dic, keys, value): for key in keys[:-1]: dic = dic. e. my_dict = {'Name': 'John', 'Age': 25, 'City': 'New York'} # Converting keys and values In the above code snippet, we are using dict comprehension to convert all the keys of a dictionary(car) to lowercase letters. lower() for k in thedict} if you're happy with your code working only in Python 2. Tried the following code: if isinstance(v, dict): for i, j in v. By the end of this tutorial Apr 27, 2023 · The modified converted list is : [{'a': 1, 'b': 2}, {'c': 3, 'd': 4}] Time complexity: O (n*n), where n is the number of key-value pairs in the dictionary. Jun 7, 2021 · Converting the nested dictionary to dataframe with, dictionary keys as column names and values corresponding to those keys as column values of the dataframe. When the orient argument is set to index, the keys of the dict will be rows. answered Jan 9, 2020 at 20:51. keys(example). casefold() will pass. which produces the output with unnecessary keys and height and weight rationalization as follows: Mar 12, 2024 · Access Value Inside Python Nested Dictionaries Using get () Method. In case you are looking for how to convert all keys of a dictionary into lower case: Python. """. Parameters: There are no parameters. Set the orient keyword argument to index. Finally, the dictionary is returned as the result. lower(): v for k, v in alphabet. 10-Aug-2022 Dec 13, 2019 · Use a dictionary comprehension and zip the list of dictionaries up with whatever list of keys you want. Removing Nested Dictionary Elements. Auxiliary space: O (n), to store the keys and values in dictionary. literal_eval, i type casted. Jan 19, 2024 · Given a flattened dictionary, the task is to convert that dictionary into a nested dictionary where keys are needed to be split at '_' considering where nested dictionary will be started. g updatedRequest['Data']['Value0']['ReferenceValue'] ). Convert values of a dictionary to lowercase How to lowercase all keys in json dict May 8, 2023 · 2. def change_dict_naming_convention(d, convert_function): """ Convert a nested dictionary from one convention to another. Initialize an empty list named ‘res’ to store the resulting dictionaries. If found, print 'Yes', otherwise 'No'. This can easily performed using just a one line with the help of list The set method in ( Setting a value in a nested python dictionary given a list of indices and value ) seems more robust to missing parental keys. There are two ways of accessing Apr 7, 2023 · Method #3: Using a for loop. Converting a list of alternative key, value items to a dictionary. Method #1: Using Naive Approach Step-by-step approach : Define a function named insert that takes two parameters, a dictionary (dct) and a list (lst). Jun 13, 2018 · And then there's the way JSON is actually used in practice. lower(): v for k, v in original_dict. Jan 26, 2021 · the problem is that you do one the comprehension inside the tuple and over the values, do it over the items instead, and the second level over the items of those Jul 11, 2010 · One more thing to take care is, ConfigParser converts the key values to lowercase hence in case you are converting the config entries to a dictionary cross check your requirements. Here's a basic example of a dictionary that I'm working with: May 2, 2013 · 0. lower() Save key and value in a new dictionary, append it to the new list; This should do it: Aug 23, 2019 · elif isinstance(d, list): result. theset = set(k. Mar 25, 2022 · In this tutorial, you’ll learn about Python nested dictionaries – dictionaries that are the values of another dictionary. Iterate nested dictionary: d = {'dict1': {'foo': 1, 'bar': 2}, 'dict2': {'baz': 3, 'quux': 4}} for i in d. The most straightforward way to create a nested dictionary is to use the {} literal syntax, where you manually specify both the keys and the values in the dictionary. items()}} print(lowercase_dict) Feb 21, 2017 · The dict_lowercase_content() makes no assumptions about what keys are present in the dictionary; it'll create a shallow copy of all the keys, and if a content key is present it is lowercased. I faced a problem because of this. If you want to convert a nested dictionary to a Pandas DataFrame, you’ll have to flatten it first. toLowerCase()] = value; }); You can convert all of the keys to upper case using toUpperCase() instead of toLowerCase(): May 18, 2017 · Basically the same way you would flatten a nested list, you just have to do the extra work for iterating the dict by key/value, creating new keys for your new dictionary and creating the dictionary at final step. items(): d1[i. – ggll Feb 10, 2020 · Here's the working code. # interface for dictionary-like objects. The flatten_dict() function has to be applied on each record in a list of dictionaries, meaning you can use either a Python loop or a list comprehension. Aug 30, 2014 · The nested list is quite large, so I've only included as sample here :) My current attempts have yielded the best option as: newDict = dict. This functi Jul 21, 2010 · If all you care is where a key is in the dict or not (i. Apart from the inbuilt method “. Exercise 2: Merge two Python dictionaries into one. fromkeys(stations,{}) Which gives me: {1: {}, 2:{}, 4:{}} To which I'm at a loss how to combine both the keys and values to make my ideal dictionary. May 23, 2023 · Solution 1: In Python, we can convert the keys and values of a dictionary to lowercase using various methods. else: d[k. first converting to list and then indexing with numbers is ok. To access a nested dictionary in Python, apply the access operator twice (or more). For example,def lower_dict(d): new_dict = dict((k. update(unnest_dict(v)) else: result[k] = v. This should do what you want: d['A']['b'] = 3. lower(), dict([ (k2. The prices of orange, grapes, and tomatoes are printed by chaining get() calls with the respective keys for fruits and vegetables, providing a safe way to handle potential missing keys. Args: d (dict): dictionary (nested or not) to be converted. If you know the key of the item you want to remove, the pop() method is a Jul 3, 2019 · One approach is to recurse on your dictionary until you find a non-dictionary value and pass down the current key as a tuple during the recursion. Dictionaries, like lists, can hold a variety of data types, including integers, floats, strings, NaN, Booleans, lists, arrays, and even nested dictionaries. Another way is to add the whole dictionary in one go, Nested_dict [dict] = { ‘key’: ‘value’}. , don't care about what value corresponds to it), then make a set instead -- i. Method #2 : Using items () + list comprehension. To convert a nested dictionary to a Pandas DataFrame: Use the DataFrame. lower()) … will work as long as: Your values are all of type dict, list, str, float, int, bool, and NoneType. items()) return new_dict a = {'Foo': Hello, 'Bar': World} print Jul 16, 2015 · I just wanted to note (as this is one of the top results for converting from a nested dictionary to a pandas dataframe) that there are other ways of nesting dictionaries that can be also be converted to a dataframe (e. For example, if the original string is “Hello World,” applying `lower ()` would result in “hello world. __delitem__(self, key): Removes the key(s) and its associated value(s) from the nested dictionary. Hot Network Questions Aug 23, 2020 · Convert a dictionary into a special dictionary python. items () to return a group of the key-value pairs in the dictionary. There are several ways to remove elements from a nested dictionary. You can build a nested dictionary with as many levels of nesting as you need. For me I was having camel-case keys hence, had to change some amount of code when I started using the dictionary instead of files. my_dict = {'KEY1': 'Hello', 'Key2': 'World'} new_dict = dict((k The older answers have some pretty good tips in them, but they all require replacing standard Python data structures (dicts, etc. items())] didn't test that out but you get the idea, also nesting that might get a little messy Jan 25, 2017 · If you don't know the number of levels, then a recursive solution is probably best: def convert_dict(d): return {str(k): convert_value(v) for k,v in d. This is inefficient, as we have to keep an entire data structure in memory just to serve as a Mar 28, 2021 · robots is a list of dictionaries, so try the following. Python Set all dictionary values to lower case with specific key. ) with custom ones, and would not work with keys that are not valid attribute names. This functi May 6, 2023 · Table of contents. You can use ast. lower()) for k, v in d. Convert all keys of the dictionary into lower case - Here I will convert all the keys of the dictionary into lower case using the lower() function. Then use list (obj) with this group as an object to convert it to a list. They are two Nov 12, 2013 · Convert all keys in dictionary to lower case with dictionary comprehension. Auxiliary space: O(N*M), as it creates a new dictionary with the same number of keys as the original dictionary, and each value in the new dictionary is a list with the same number of elements as the corresponding value in the original dictionary. lower(), v. Here’s an example: def flatten_dict(d: dict) -> dict: I wish to convert all the objects to dictionaries. nesting via columns). Hope I'm making sense here. keys() ])) for k1 in myDict. append(tuple(keys + [d])) return result. lower ()` method to make a Python dictionary case insensitive: python. 4. The first version works, and it's somewhat fast. In data analysis, nested dictionaries can be used to store and manipulate complex data Python How to Access Nested Dictionary (with 5+ Examples) By Artturi Jalli. Syntax: For any nested dictionary, it finds it will flatten it in a way that the key renames to the full path. ”. If the value is not a dictionary, it is left unchanged. Here is an example using a subset of ascii lowercase letters: { pair[0]: pair[1] for pair in list(zip([*string. you'll need to nest another dictionary comprehension inside. Create an outer defaultdict with dict as its default value. Let’s demonstrate a bad practice first, so you can get the idea of why flatten the data. Any help would be hugely appreciated! Feb 7, 2019 · I am writing a python application where I have a variable dictionary that can be nested upto any level. May 6, 2024 · Using a nested dictionary in Python is a way to create a hierarchical data structure for your application. The keys are not able to be changed. Otherwise, it simply updates the value in the source dictionary. Mar 21, 2023 · Explanation : List converted to dictionary with index keys, just one row. lower() method, it converts those letters to lowercase. We are also using the lower() function of Python String to convert the key text to lowercase. So far, this is the best I can come up with, but it doesn't recurse Oct 24, 2017 · As you can see flattenReturn generates a new dict filtering the values which are dictionaries and then updates it with their key-values to flatten it while the second option modifies the dict in place. using ast. 7 or later for the sake of some purely Jan 2, 2021 · Convert all keys in dictionary to lower case with dictionary comprehension. Loop through each key-value pair in the original dictionary. 0. basically if you replace [int(v)] with something like [dict((a,int(b) for (a,b) in v. d = {“Name”: “John Smith”, “Age”: 25, “Occupation”: “Software Engineer”} Convert the keys to lowercase. I think I can work a very crude solution but I'm hoping there might be something a bit simpler. update(dict((k, v. Python3. so it will work for resp = 'GBR' or 'gbr'. forEach(key => { const value = example[key]; delete example[key]; example[key. dumps(d, ensure_ascii=False). iteritems()} Result. values()[0] but a dictionary is the wrong data structure for this type of thing. I had a similar problem to solve: I wanted to replace keys in underscore lowercase convention for camel case convention and vice versa. Dict = { } . Let’s explore how to create and use this data type! Nov 3, 2022 · Then with the . DictWriter writes each row with a dict of the following pattern: {column1: data, column2: data, column3: data, } And you have to give the fieldnames, because a dict is unordered. For example, let’s access the name of a student data dictionary with the student ID of 123: students = {. Then, you can simply loop through your list of tuples once, setting the values appropriately as you go. Returns: A view object is returned that displays all the keys. However, it has a problem. You can update the list using the below code: item. Return the “converted_dict”. Other Ways to Convert a Python String to Lowercase. Converting nested dictionary to dataframe with the keys as rownames and the dictionaries in the values This is my favorite, to only convert the keys, which is what I was looking for. That looks like this: output = {. In each iteration, the key-value pair is added to the dictionary using the current element as the key and the next element as the value. loads method. items(): # the key will be a flattened tuple. def nested_keys(d) -> set: """. the following nested dictionary Sep 11, 2023 · Python Nested Dictionaries in Real-World Applications. upper()] = v. The resulting dictionary has sections as keys which point to a dict of the sections options as key => value pairs. Here ( Data Science Learner ) is some code tweaks with output and sample python code. If you want to create a nested dictionary given a list (arbitrary length) for a path and perform a function on an item that may exist at the end of the path, this handy little recursive function is quite helpful: def ensure_path(data, path, default=None, default_func=lambda x: x): """. def flatten_dict(deep_dict): def do_flatten(deep_dict, current_key): for key, value in deep_dict. Jul 28, 2014 · What I need is a multiindex where each level corresponds to the keys in the nested dict and the rows corresponding to each element in the list as shown above. array (data) with this list as data to convert it to an array. As a bonus, I've also supported lists and tuples during the recursion, in addition to the set on the provided example. Method #1 : Using loop + enumerate () This is brute way in which this task can be performed. And the way it's implemented by Python's json module. When applied to a string, it converts all the characters in the string to lowercase. Apr 20, 2023 · Write a Python Program to find sequences of one upper case letter followed by lower case letters. append(tuple(keys + d)) elif isinstance(d, set) or isinstance(d, tuple): result. lower or str. Oct 28, 2020 · 4. How to create a nested dictionary from a Apr 10, 2023 · The function takes a nested dictionary, a list of keys, and a value as inputs. nested_dict = { 'dictA': {'key_1': 'value_1'}, 'dictB': {'key_2': 'value_2'}} Here, the nested_dict is a nested dictionary with the dictionary dictA and dictB. If you're comfortable with list and dictionary comprehension, you can zip up x with a lists of your key lists and values lists. Examples: Input: dictionary = {'Hello': 600, 'world': 300, 'BTechGeeks': 900 Feb 1, 2019 · I have a nested dictionary that looks like this: data = {'Name': {}, 'Contact': {} } It might seem clear that what I'm trying to do is take the names and phone numbers from the JSON and sort them into the nested dictionary under the correct keys. You’ll learn how to create nested dictionaries, access their elements, modify them and more. items(): if k == key: d[k] = value elif isinstance(v, dict): update_nested_dict(v, key, value) This recursive function circulates through the dictionary and its sub Apr 28, 2017 · >>> myDict = {'myKey': {'myKey2': [u'Abc']}} >>> newDict = dict([ (k1. lower()) for k,v in item. If it is, then it iterates over each key-value pair in the Aug 18, 2023 · Convert a List to a Dictionary using a loop. 5+, the ** unpacking operator can be used within a dictionary comprehension to neatly convert keys and values to lowercase in a single line of code. Because there is an unknown number of 'Value' keys, I'm uncertain as to what Apr 18, 2023 · Nested Dictionary Python to Pandas DataFrame. Exercise 4: Initialize dictionary with default values. My issue when attempting to convert this into a Python usable dictionary (e. Python set dictionary nested key with dot delineated string. What is Nested Dictionary in Python? In Python, a nested dictionary is a dictionary inside a dictionary. Jun 17, 2020 · How to convert Python dictionary keys values to lowercase - You can convert Python dictionary keys/values to lowercase by simply iterating over them and creating a new dict from the keys and values. setdefault(key, {}) dic[keys[-1]] = value. dict. The keys in any level can be either int or string. items(): if isinstance(v, dict): result. lower ()` method on each key in the dictionary. Small typo: you need an additional () around the dict() argument that is returned. This is useful when you have non-ascii characters and matching with ascii versions(eg: maße vs masse). This will convert all the values to lower, But according to the condition we should focus on only key1 which need to be lower. Using {} Literal Syntax. df = [ {'A': " {'value': '1'}", 'B': " {'value': '2'}"}] Mar 14, 2022 · pop(self, key, default=None): Removes and returns the value associated with the given key(s) from the nested dictionary, or returns the default value if the key(s) is not found. g. But I'll summarize here: lowered = json. upper()] = j. Oct 19, 2020 · You can use dict. If the list of keys has only one key, the function adds the value to the nested dictionary at that key. Examples: Input : GeeksOutput : YesInput : geeksforgeeksOutput : NoPython regex to find sequences of one upper case letter followed by lower case lettersUsing re. I'm new to python and have tried several approaches but failed in achieving so, please help. Convert the value to a string using the str () function. Start a for loop to iterate over each nested tuple in ‘test_tuple’. In this, we iterate through the index and value together using enumerate and create custom required dictionary. Use regular expressions to replace ‘,’ with ‘-‘ or ‘^’ for list or tuple values respectively. May 18, 2014 · To change a single dictionary just reference the dictionary you want to change. The DataFrame. Thanks for pointing it out, i have updated my answer. 6. for i in d: print i for j in d[i]: print j output: Apr 9, 2023 · Time complexity: O(N*M), where N is the number of keys in the dictionary and M is the length of the longest list in the dictionary. >>> d = {'data1': {'yes': 'abc'}, 'data2': {'yes': 'xyz'}} >>> d['data1']['no'] = d Jun 7, 2012 · I came up with one scenario where in I wanted to use json. This method works by initializing an empty dictionary and then iterating through the list in step 2. Mar 5, 2023 · As a pre-task follow this simple three steps. lower() for k in thedict) (in every version of Python, or {k. Nested dictionaries in Python are not just a theoretical concept — they have practical applications in various fields such as data analysis and web development. If you want to get all nested keys of a dictionary, you will need to define your own function. Feb 10, 2022 · Your nested key seems like a JSON string that can be loaded into a dictionary using json. 123: {'name' : 'Alice', 'age': '23'}, Jun 9, 2015 · Just use a comprehension to run through the dictionary again and convert all keys to lowercase. Converting two lists of the same length to a dictionary. lower()”, there are different ways of converting uppercase letters to lowercase letters in Python. In short, I'm trying to do the following: take a nested value and switch it with a non-nested key; rename a nested key. from_dict() method. Below are some common methods to create a Python Nested Dictionary. x, Feb 12, 2024 · Given a flattened dictionary, the task is to convert that dictionary into a nested dictionary where keys are needed to be split at '_' considering where nested dictionary will be started. First of all call dict. This results in a complete merging of the dictionaries at all levels. The main block I'm struggling with is here: For simple situations, you can use the following example to convert all keys to lower case: Object. literal_eval like below - df [column_name] = df [column_name]. loads() I get the following output: So far so good, I can access the Data value via updatedRequest['Data']. e. 1. Add the key-value pair to the “converted_dict”. apply (ast. Oct 25, 2019 · If you're fine with losing the key to which your inner dict belongs to (you did not specify what to do with it), I would do it recursively: def unnest_dict(d): result = {} for k,v in d. for eg. May 10, 2023 · This method uses a dictionary comprehension to create a new dictionary where all keys are converted to upper case. ascii_lowercase[0:len(input)]], input))} Jan 31, 2018 · I'm working with a nested dictionary and I'm trying to figure out how to modify certain nested and non-nested keys/values effectively. Remove an Item by Key. alphlower = {k. Explanation: When you write d['A'] you are getting another dictionary (the one whose key is A), and you can then use another set of brackets to add or access entries in the second dictionary. sections (): the_dict [section] = {} for key, val in If your purpose is to matching with another string by converting in one pass, you can use str. Iterate over dictionaries in the list robots; Iterate over keys in each dictionary; Get value of each key in dictionary, convert them to lowercase using . Jan 10, 2019 · After conversion using json. upper()] = d1. loads(json. To do this, we simply need to call the `str. Though the nested JSON won't get converted to the dictionary that's why I've added the recursive function to address the nested dictionary present in the JSON. A list would be more suitable.
ys pt jh do gt pq sx qw ke cf