nodes: 0, module; 1, function_definition; 2, function_name:deserialize; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:value; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, if_statement; 11, if_statement; 12, return_statement; 13, comment:"""
          Generates a Peer instance via a JSON string of the sort generated
          by `Peer.deserialize`.
  
          The `name` and `ip` keys are required to be present in the JSON map,
          if the `port` key is not present the default is used.
          """; 14, assignment; 15, comparison_operator:"name" not in parsed; 16, block; 17, comparison_operator:"ip" not in parsed; 18, block; 19, comparison_operator:"port" not in parsed; 20, block; 21, call; 22, identifier:parsed; 23, call; 24, string:"name"; 25, identifier:parsed; 26, raise_statement; 27, string:"ip"; 28, identifier:parsed; 29, raise_statement; 30, string:"port"; 31, identifier:parsed; 32, expression_statement; 33, identifier:cls; 34, argument_list; 35, attribute; 36, argument_list; 37, call; 38, call; 39, assignment; 40, subscript; 41, subscript; 42, subscript; 43, identifier:json; 44, identifier:loads; 45, identifier:value; 46, identifier:ValueError; 47, argument_list; 48, identifier:ValueError; 49, argument_list; 50, subscript; 51, identifier:DEFAULT_PEER_PORT; 52, identifier:parsed; 53, string:"name"; 54, identifier:parsed; 55, string:"ip"; 56, identifier:parsed; 57, string:"port"; 58, string:"No peer name."; 59, string:"No peer IP."; 60, identifier:parsed; 61, string:"port"
code: def deserialize(cls, value):
          """
          Generates a Peer instance via a JSON string of the sort generated
          by `Peer.deserialize`.
  
          The `name` and `ip` keys are required to be present in the JSON map,
          if the `port` key is not present the default is used.
          """
          parsed = json.loads(value)
  
          if "name" not in parsed:
              raise ValueError("No peer name.")
          if "ip" not in parsed:
              raise ValueError("No peer IP.")
          if "port" not in parsed:
              parsed["port"] = DEFAULT_PEER_PORT
  
          return cls(parsed["name"], parsed["ip"], parsed["port"])