old_contents: import json
  
  
  def is_transformed(transform, predicate, *args, exceptions=[
      Exception
  ], msg='data can\'t be transformed', **kwargs):
      """
      Generates a predicate that checks if the data is valid according to some
      predicate after a function has been applied to the data. If this function
      throws an exception the predicate will consider the data invalid.
  
      With the ``exceptions`` parameter you can limit the exceptions that the
      predicate catches. With the ``msg`` parameter you can specify what the
      explanation should be when the predicate catches an exception.
  
      The predicate that this function returns also has an optional ``include``
      parameter, if you set this to ``True`` the data after the transformation
      will also be returned in case the transformation was succesful.
  
      All other arguments provided will be passed on to the transform function.
      """
      def is_valid(data, explain=False, include=False):
          try:
              data = transform(data, *args, **kwargs)
          except Exception as e:
              if not any(isinstance(e, exc) for exc in exceptions):
                  raise e
              return (
                  (False, msg, None) if explain else (False, None)
              ) if include else (
                  (False, msg) if explain else False
              )
          return ((
              predicate(data, explain=True) + (data,)
          ) if explain else (
              predicate(data), data
          )) if include else predicate(data, explain=explain)
      return is_valid
  
  
  def is_json(predicate, *args, loader=json.loads, **kwargs):
      """
      Generates a predicate that checks if the data is valid according to some
      predicate after it has been decoded as JSON. The predicate considers the
      data invalid if it is invalid JSON.
  
      With the ``loader`` parameter you can specify a different loader than the
      default JSON loader.
  
      All other arguments provided will be passed on to the JSON loader.
      """
      return is_transformed(loader, predicate, *args, exceptions=[
          json.JSONDecodeError
      ], msg='data is not valid json', **kwargs)
  
new_contents: import json
  
  
  def is_transformed(
      transform, predicate, *args,
      exceptions=[Exception], msg='data can\'t be transformed', **kwargs
  ):
      """
      Generates a predicate that checks if the data is valid according to some
      predicate after a function has been applied to the data. If this function
      throws an exception the predicate will consider the data invalid.
  
      With the ``exceptions`` parameter you can limit the exceptions that the
      predicate catches. With the ``msg`` parameter you can specify what the
      explanation should be when the predicate catches an exception.
  
      The predicate that this function returns also has an optional ``include``
      parameter, if you set this to ``True`` the data after the transformation
      will also be returned in case the transformation was succesful.
  
      All other arguments provided will be passed on to the transform function.
      """
      def is_valid(data, explain=False, include=False):
          try:
              data = transform(data, *args, **kwargs)
          except Exception as e:
              if not any(isinstance(e, exc) for exc in exceptions):
                  raise e
              return (
                  (False, msg, None) if explain else (False, None)
              ) if include else (
                  (False, msg) if explain else False
              )
          return ((
              predicate(data, explain=True) + (data,)
          ) if explain else (
              predicate(data), data
          )) if include else predicate(data, explain=explain)
      return is_valid
  
  
  # Python <=3.4 compatibility
  try:
      jsonError = json.JSONDecodeError
  except AttributeError:
      jsonError = ValueError
  
  
  def is_json(predicate, *args, loader=json.loads, **kwargs):
      """
      Generates a predicate that checks if the data is valid according to some
      predicate after it has been decoded as JSON. The predicate considers the
      data invalid if it is invalid JSON.
  
      With the ``loader`` parameter you can specify a different loader than the
      default JSON loader.
  
      All other arguments provided will be passed on to the JSON loader.
      """
      return is_transformed(
          loader, predicate, *args,
          exceptions=[jsonError], msg='data is not valid json', **kwargs
      )
  
subject: Add python3.4 compatibility to is_json