HTTP Part Serializers and Parsers
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 OpenAPI 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 = OpenApi.of(HttpPartType.HEADER, schema, value);
// Produces "[[1,2,3],[4,5,6],[7,8,9]]
long[][] value = OpenApi.to(HttpPartType.HEADER, schema, output, long[][].class);
The HttpPartSchema class also provides convenience static methods for creation of custom schemas.
The equivalent to the schema above can be structured like so:
import static org.apache.juneau.httppart.HttpPartSchema.*;
// Schema information about our part.
HttpPartSchema schema = tArrayPipes(tArrayCsv(tInt64())).build();
The class hierarchy for the part marshallers are: