Class JsonSchemaBodyDecoder

java.lang.Object
org.mockserver.codec.JsonSchemaBodyDecoder

public class JsonSchemaBodyDecoder extends Object
  • Constructor Details

  • Method Details

    • convertToJson

      public String convertToJson(HttpRequest request, BodyMatcher<?> bodyMatcher)
    • convertToJson

      public String convertToJson(BodySource source, BodyMatcher<?> bodyMatcher)
      Shared conversion used by both request matching (HttpRequest) and response matching (HttpResponse), driven only through the BodySource abstraction. For an XML or form Content-Type the body is converted to JSON so a JSON / JSON schema / JSON path matcher can match an XML or form actual body; otherwise the body string is returned unchanged (including null for an absent body, which the JSON matchers treat as a clean non-match). The XML→JSON conversion is memoised per message via BodySource.getOrComputeConvertedBody(Supplier) so it runs once per message, not once per candidate matcher.