input: Write a function to implement a basic blockchain system in Python. The function should include a Block class to represent each block in the chain, a Blockchain class to manage the chain, and methods to add blocks and retrieve the entire chain in JSON format.
  
  
  import hashlib
  import json
  
  def sha256(data):
      hash_function = hashlib.sha256()
      hash_function.update(data.encode('utf-8'))
      return hash_function.hexdigest()
  
  class Block:
      def __init__(self, index, timestamp, data, previous_hash):
          self.index = index
          self.timestamp = timestamp
          self.data = data
          self.previous_hash = previous_hash
          self.hash = sha256(f'{self.index}{self.timestamp}{self.data}{self.previous_hash}')
  
  class Blockchain:
      def __init__(self):
          self.chain = []
  
      def add_block(self, data):
          previous_hash = self.chain[-1].hash if len(self.chain) > 0 else None
          block = Block(len(self.chain), data['timestamp'], data['data'], previous_hash)
          self.chain.append(block)
  
      def get_chain(self):
          return json.dumps([b.__dict__ for b in self.chain], indent=2)
  
  assert Blockchain.add_block({}) == None
  assert Blockchain.get_chain() == "[]"
  assert Blockchain.add_block({'timestamp': '2023-10-01', 'data': 'Block 1'}) == None
  assert Blockchain.get_chain() != "[]"
  assert Blockchain.add_block({'timestamp': '2023-10-02', 'data': 'Block 2'}) == None
  assert Blockchain.get_chain().find('Block 1') != -1
  assert Blockchain.get_chain().find('Block 2') != -1
  
output: 
  import hashlib
  import json
  
  def sha256(data):
      hash_function = hashlib.sha256()
      hash_function.update(data.encode('utf-8'))
      return hash_function.hexdigest()
  
  class Block:
      def __init__(self, index, timestamp, data, previous_hash):
          self.index = index
          self.timestamp = timestamp
          self.data = data
          self.previous_hash = previous_hash
          self.hash = sha256(f'{self.index}{self.timestamp}{self.data}{self.previous_hash}')
  
  class Blockchain:
      def __init__(self):
          self.chain = []
  
      def add_block(self, data):
          previous_hash = self.chain[-1].hash if len(self.chain) > 0 else None
          block = Block(len(self.chain), data['timestamp'], data['data'], previous_hash)
          self.chain.append(block)
  
      def get_chain(self):
          return json.dumps([b.__dict__ for b in self.chain], indent=2)
  