code: def json_encode(data_type, obj, caller_permissions=None, alias_validators=None, old_style=False,
                  should_redact=False):
      
      for_msgpack = False
      serializer = StoneToJsonSerializer(
          caller_permissions, alias_validators, for_msgpack, old_style, should_redact)
      return serializer.encode(data_type, obj)
docs: Encodes an object into JSON based on its type.
  
      Args:
          data_type (Validator): Validator for obj.
          obj (object): Object to be serialized.
          caller_permissions (list): The list of raw-string caller permissions with which
                  to serialize.
          alias_validators (Optional[Mapping[bv.Validator, Callable[[], None]]]):
              Custom validation functions. These must raise bv.ValidationError on
              failure.
  
      Returns:
          str: JSON-encoded object.
  
      This function will also do additional validation that wasn't done by the
      objects themselves:
  
      1. The passed in obj may not have been validated with data_type yet.
      2. If an object that should be a Struct was assigned to a field, its
         type has been validated, but the presence of all required fields
         hasn't been.
      3. If an object that should be a Union was assigned to a field, whether
         or not a tag has been set has not been validated.
      4. A list may have passed validation initially, but been mutated since.
  
      Example of serializing a struct to JSON:
  
      struct FileRef
         path String
         rev String
  
      > fr = FileRef()
      > fr.path = 'a/b/c'
      > fr.rev = '1234'
      > JsonEncoder.encode(fr)
      "{'path': 'a/b/c', 'rev': '1234'}"
  
      Example of serializing a union to JSON:
  
      union UploadMode
          add
          overwrite
          update FileRef
  
      > um = UploadMode()
      > um.set_add()
      > JsonEncoder.encode(um)
      '"add"'
      > um.update = fr
      > JsonEncoder.encode(um)
      "{'update': {'path': 'a/b/c', 'rev': '1234'}}"