Skip to main content

Array Serialization Formats

APIs implement various array serialization schemes based on their specific use cases. To ensure broad compatibility, APIMatic supports six array serialization methods for query and form parameters: Indexed, UnIndexed, Plain, CSV, PSV, and TSV.

Configure Array Serialization

To leverage this feature, use the ArraySerialization CodeGen setting to define your preferred array serialization format. The default format is Indexed:

"info": {
...,
"x-codegen-settings": {
"ArraySerialization": "Indexed"
}
}

Serialization Formats and Examples

The following formats are supported for form and query parameters:

Indexed array serialization includes an explicit index for each value.

businessAsset[0]=1&businessAsset[1]=2

Usage in SDK

Array serialization can be utilized during request construction or deserialization within SDKs generated using APIMatic. Here’s a usage example:

const businessAsset: number[] = [
1,
2
];

async function makeApiCall() {
try {
const { result, ...httpResponse } = await controller.getArraySerializedInQuery(businessAsset);
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
}
}
};
makeApiCall();