def _JsonDecodeKey(d):
    """Json decode a ndb.Key object."""
    k_c = d['key_string']
    if isinstance(k_c, (list, tuple)):
        return ndb.Key(flat=k_c)
    return ndb.Key(urlsafe=d['key_string'])