xxxxxxxxxx
import json
# JSON object
json_data = '''
{
"name": "John",
"age": 30,
"city": "New York"
}
'''
# Define a class
class Person:
def __init__(self, name, age, city):
self.name = name
self.age = age
self.city = city
# Convert JSON to Python class object
person_data = json.loads(json_data)
person = Person(person_data["name"], person_data["age"], person_data["city"])
# Access the class attributes
print(person.name) # Output: John
print(person.age) # Output: 30
print(person.city) # Output: New York