Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python convert json string to class

class Person():
    def __init__(self, name, age):
        self.name = name
        self.age = age

person_string = '{"name": "Bob", "age": 25}'

person_dict = json.loads(person_string)
person_object = Person(**person_dict)

print(person_object)
Source by www.adamsmith.haus #
 
PREVIOUS NEXT
Tagged: #python #convert #json #string #class
ADD COMMENT
Topic
Name
6+3 =