Skip to content
CoolDeveloper101 edited this page Nov 20, 2019 · 4 revisions

Welcome to the json-2.0-python wiki! Here is an example on how to use this module.

class User:

  def __init__(self, username, password, email):
    self.username = username
    self.password = password
    self.email = email
  
  def __repr__(self):
    return f'User({self.username})'
    
    
test_user = User("testing", '1234', 'testing@email.com')

# Let's say I want to store this test_user. So I can do:

import json2

dumped_data = json2.dumps({'User': test_user})

# if you want to load the dumped_data, you can use the loads method

json2.loads(dumped_data)
Clone this wiki locally