Within the Nextmv Cloud, the API expects JSON
input and output. If you want to work with a format for input/output that is not JSON
, you can use JSON
as a wrapper for non-JSON
input and output.
As an example, we'll walk through how to use CSV
as the non-JSON
input and output format. The same approach can be used for other formats.
Input
We take a CSV
input and encode it as a base64
string. We then create a JSON
object with a data
key. The value of the data
key is the base64
-encoded string. That input JSON
can then be sent to the Nextmv cloud.
Sample CSV
input
Convert to JSON
To automatically convert your CSV
input you would write code to transform it to the structure outlined in the beginning. We provide some code snippets below to help you get started.
Now the original CSV
input is wrapped in a JSON
object, so we can submit it to the Nextmv cloud and let your custom application handle the input.
Output
Define the output format
If you want to also emit non-JSON
output, you can use the same approach using the data
key. In your custom application you'll have to write code that encodes the non-JSON
output as a base64
string.
In addition, you can add statistics
information to the JSON
object. The statistics
key has to follow the statistics convention and it allows you to experiment with your application.
The output would then look like the snippets below.
In case you want to follow the Nextmv Go SDK runner convention, you can return an array of solutions
instead of a single solution
.
Decode the output after the run
When pulling the results from Nextmv Cloud you will have to decode the base64
encoded data similiar to what we have done for encoding the input. Below are code snippets to help you get started more quickly. They operate on an output with a data
key in the root object.