{title:'HTTP Part Serializers and Parsers', updated:'8.2.0,9.0.0'}

There is a separate set of serializers and parsers for marshalling HTTP parts (query, form-data, headers, path variables, and plain-text request bodies). The distinction is that these are designed to marshall directly to-and-from strings based on Open-API schema information.

| // Schema information about our part. | HttpPartSchema schema = HttpPartSchema | .tArrayPipes() | .items( | HttpPartSchema | .tArrayCsv() | .items( | HttpPartSchema.tInt64("integer","int64") | ) | ) | .build(); | | // Our value to serialize | Object value = new long[][]{{1,2,3},{4,5,6},{7,8,9}}; | | // Produces "1,2,3|4,5,6|7,8,9" | String output = OpenApiSerializer.DEFAULT.serialize(HttpPartType.HEADER, schema, value); | | // Produces "[[1,2,3],[4,5,6],[7,8,9]] | long[][] value = OpenApiParser.DEFAULT.parse(HttpPartType.HEADER, schema, output, long[][].class);

The {@link oaj.httppart.HttpPartSchemaBuilder} class is provided for shortening the creation of schemas. The equivalent to the schema above can be structured like so:

| import static org.apache.juneau.httppart.HttpPartSchemaBuilder.*; | | // Schema information about our part. | HttpPartSchema schema = tArrayPipes(tArrayCsv(tInt64())).build();

The class hierarchy for the part marshallers are:

- {@link oaj.httppart.HttpPartSerializer}
  - {@link oaj.httppart.SimplePartSerializer} - Serializes directly to strings.
  - {@link oaj.uon.UonSerializer} - Serializes to UON notation.
    - {@link oaj.oapi.OpenApiSerializer} - Serializes using Open-API schema rules.
- {@link oaj.httppart.HttpPartParser}
  - {@link oaj.httppart.SimplePartParser} - Parses directly from strings.
  - {@link oaj.uon.UonParser} - Parses from UON notation.
    - {@link oaj.oapi.OpenApiParser} - Parses using Open-API schema rules.