StediDOCS

Converter

Stedi Converter API

Download OpenAPI

Convert CSV to JSON

POST/csv_to_json
Converts CSV to JSON.
Request body

application/json

Requiredstring

The CSV document you want to convert to JSON, provided as a string. The converter will do its best to detect delimiters and end-of-line characters, or you can use the options field to specify those explicitly.

Optionalobject
Options that tell the converter how to interpret the CSV document.
CsvToJsonOptions object.

Example

POST
https://converter.stedi.com/2021-10-01/csv_to_json

Convert JSON to CSV

POST/json_to_csv
Converts JSON to CSV.
Request body

application/json

Requiredarray

The JSON document you want to convert to CSV. The document can either be an array of arrays or an array of objects. If it's an array of arrays, each array will be turned into a row. If it's an array of objects, the values of each object will be turned into a row and the keys will be used as headers.

Here's an example of an array of arrays.

[
  [ "fruit", "color", "taste" ],
  [ "kiwi", "green", "sweet" ],
  [ "cranberry", "red", "tart" ]
]

Here's an example of an array of objects.

[
  {
    "fruit": "kiwi",
    "color": "green",
    "taste": "sweet"
  },
  {
    "fruit": "cranberry",
    "color": "red",
    "taste": "tart"
  }
]

Both examples result in the same CSV.

fruit,color,taste
kiwi,green,sweet
cranberry,red,tart

Values in the JSON document can be a string, a number, or a boolean. If your JSON is an array of objects, the value may be an object, but only if the flatten option is set to true.

You should include the input in the request body as JSON, not as a string.

Array of object objects.

Optionalobject
Options that tell the converter what the generated CSV should look like.
JsonToCSVOptions object.

Example

POST
https://converter.stedi.com/2021-10-01/json_to_csv

Convert XML to JSON

POST/xml_to_json
Converts XML to JSON.
Request body

application/json

Requiredstring

The XML document you want to convert to JSON, provided as a string. The output JSON will be an array of objects. An element name is converted into a JSON key, inner text of an element is converted into a value, and nested elements are converted into nested objects. By default, attributes are ignored, but you can change that using the ignore_attributes option.

For example, consider the following XML. (For clarity, the XML document is not formatted as a string here, but it should be in your request.)

<?xml version="1.0" encoding="UTF-8"?>
<food>
  <fruit>
    <name>kiwi</name>
    <color>green</color>
    <taste>sweet</taste>
  </fruit>

  <fruit>
    <name>cranberry</name>
    <color>red</color>
    <taste>tart</taste>
  </fruit>
</food>

The resulting JSON looks like this.

{
  "output": {
    "?xml": "",
    "food": {
      "fruit": [
        {
          "name": "kiwi",
          "color": "green",
          "taste": "sweet"
        },
        {
          "name": "cranberry",
          "color": "red",
          "taste": "tart"
        }
      ]
    }
  }
}
Optionalobject
Options that tell the converter how to interpret the XML document and what the generated JSON should look like.
XmlToJsonOptions object.

Example

POST
https://converter.stedi.com/2021-10-01/xml_to_json