input: Write a function to implement a basic blockchain system in Python. The function should include a class for each block and a class for the blockchain. The chain should be able to add blocks with data and return the entire blockchain in JSON format. If the chain is empty, the function should handle it appropriately.
  
  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().get_chain() == '[]'
  blockchain = Blockchain()
  blockchain.add_block({'timestamp': '2023-01-01T00:00:00', 'data': 'Block data 1'})
  assert json.loads(blockchain.get_chain())[0]['data'] == 'Block data 1'
  blockchain.add_block({'timestamp': '2023-01-02T00:00:00', 'data': 'Block data 2'})
  assert len(json.loads(blockchain.get_chain())) == 2
output: 
  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)
  