VOOZH about

URL: https://www.geeksforgeeks.org/python/convert-nested-python-dictionary-to-object/

⇱ Convert nested Python dictionary to object - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Convert nested Python dictionary to object

Last Updated : 28 Feb, 2023

Let us see how to convert a given nested dictionary into an object 

Method 1 : Using the json module. We can solve this particular problem by importing the json module and use a custom object hook in the json.loads() method. 


Output
1
2
E
3
4

Time complexity: O(n), where n is the total number of elements in the input dictionary.
Auxiliary space: O(n), where n is the total number of elements in the input dictionary

Method 2: Using the isinstance() method

We can solve this particular problem by using the isinstance() method which is used to check whether an object is an instance of a particular class or not. 


Output
1
2
E
3
4
Comment
Article Tags:
Article Tags: