input: Write a function to create and manage a basic blockchain system in Python. The function should include a class for blocks and a class for the blockchain, and it should allow adding new blocks to the blockchain. The function should also include a method to return the entire blockchain in JSON format.
  assert get_chain()==json.dumps([], indent=2)
  chain = Blockchain()
  chain.add_block({'timestamp': '2023-01-01T12:00:00Z', 'data': 'Block 1'})
  chain.add_block({'timestamp': '2023-01-02T12:00:00Z', 'data': 'Block 2'})
  assert chain.chain[0].hash=='ef92b778bafe771e89245b89ecbc08a44a4e166c06659911881f383d4473e94f'
  assert chain.chain[1].hash=='8d85ea92bdfe44cdff52afed65d10c2193ea84f1f2e5e3e49b9fd49cf8ccf4d7'
  assert get_chain()==json.dumps([
      {
          "index": 0,
          "timestamp": "2023-01-01T12:00:00Z",
          "data": "Block 1",
          "previous_hash": None,
          "hash": "ef92b778bafe771e89245b89ecbc08a44a4e166c06659911881f383d4473e94f"
      },
      {
          "index": 1,
          "timestamp": "2023-01-02T12:00:00Z",
          "data": "Block 2",
          "previous_hash": "ef92b778bafe771e89245b89ecbc08a44a4e166c06659911881f383d4473e94f",
          "hash": "8d85ea92bdfe44cdff52afed65d10c2193ea84f1f2e5e3e49b9fd49cf8ccf4d7"
      }
  ], indent=2)
output: import hashlib
  import json
  import time
  
  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 = self.calculate_hash()
  
      def calculate_hash(self):
          block_string = json.dumps({"index": self.index, "timestamp": self.timestamp, "data": self.data, "previous_hash": self.previous_hash}, sort_keys=True).encode()
          return hashlib.sha256(block_string).hexdigest()
  
  class Blockchain:
      def __init__(self):
          self.chain = [self.create_genesis_block()]
  
      def create_genesis_block(self):
          return Block(0, "2023-01-01T12:00:00Z", "Genesis Block", None)
  
      def add_block(self, data):
          previous_block = self.chain[-1]
          new_block = Block(previous_block.index + 1, time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()), data, previous_block.hash)
          self.chain.append(new_block)
  
      def get_chain(self):
          return json.dumps([{"index": block.index, "timestamp": block.timestamp, "data": block.data, "previous_hash": block.previous_hash, "hash": block.hash} for block in self.chain], indent=2)