CSV to Json

Provides the ability to transform a text, comma separated data source into a JSON array structure.

Version 1

HTTP Request
POST /ado/v1/CsvToJson

Header

ParameterDescription
Ocp-Apim-Subscription-KeyThe subscription key you received when you purchased a plan.

Request Body

Mandatory

ParameterTypeDescription
datastringThe data.

Optional

ParameterTypeDescription
delimiterstringDefault is a , (comma) but can be changed to any separator as specified in your data set.
rowSeparatorstringThe characters used to delimit each row. The default value is \n
headerRowbooleanDo the contents in the data source contain a header row with field names? Default is true
escapeCharacterstringThe escape character is required in situations where the value of a field contains the character that delimits one field from the others. Default is "
encodingstringUse this in cases where the contents of the file are not encoded in a UTF8 format. All possible values are:
ASCII
UTF8
UTF16LittleEndian
UTF16BigEndian
ISO-8859-1

Common

Further Documentation: Common Parameters

ParameterTypeDescription
filterStringA fully functioning SQL based WHERE statement that will filter the outgoing dataset to the records it determines as being included.
sortOrderObjectSorts the resulting dataset by the criteria provided.
The object should contain property names that represent properties contained within the resulting dataset with a value corresponding to the desired sort direction (i.e. ASC or DESC).
schemaObjectYou can use this parameter to override the inferred schema for properties in the incoming dataset(s).
A field will be inferred unless specific explicitly within this object.
advancedOptionsObjectIs an object with the following properties.

cultureName (String)
The specified culture determines the behaviour for aspects related to formatting numeric values and dates. Is extremely important when converting strings to dates, e.g. 05/03/2022 will be treated differently between locales. For more information on the accepted values for this property, please consult the documentation from Microsoft … https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo?view=net-6.0#culture-names-and-identifiers

isBoolean (string[])
A list of strings that are the names of all properties in the resulting dataset that should be treated as boolean values.

By default, the framework treats boolean values as 1 (true) or 0 (false). In order to differentiate the integer as a boolean, the property in question needs to be called out explicitly in this list.

Notes

The field delimiter for the contents contained within the data parameter is a comma.

Examples

With Header Row
Without Header Row

This example demonstrates a simple data set with a header row and a single data record.

Request

{
    "headerRow": true,
    "data": "Header 1,Header 2,Header 3,Header 4\nValue1,Value,Value 3,Test\nValue2.1,Value 3.1,Value 4.1,Value Test"
}
Code language: JSON / JSON with Comments (json)

Response

[
    {
        "Header 1": "Value1",
        "Header 2": "Value",
        "Header 3": "Value 3",
        "Header 4": "Test"
    },
    {
        "Header 1": "Value2.1",
        "Header 2": "Value 3.1",
        "Header 3": "Value 4.1",
        "Header 4": "Value Test"
    }
]
Code language: JSON / JSON with Comments (json)

The source data for this example was taken from this location … https://sample-videos.com/download-sample-csv.php#google_vignette.

A schema was added to demonstrate the ability for the framework to convert specific fields in the output dataset to different data types as required.

The headerRow variable is set to false given the first row is not a header record.

Request

{
    "headerRow": false,
    "schema": {
        "Field1": "Int",
        "Field5": "Double",
        "Field6": "Double"
    },    
    "data": "1,\"Eldon Base for stackable storage shelf, platinum\",Muhammed MacIntyre,3,-213.25,38.94,35,Nunavut,Storage & Organization,0.8\n2,\"1.7 Cubic Foot Compact \"\"Cube\"\" Office Refrigerators\",Barry French,293,457.81,208.16,68.02,Nunavut,Appliances,0.58\n3,\"Cardinal Slant-D® Ring Binder, Heavy Gauge Vinyl\",Barry French,293,46.71,8.69,2.99,Nunavut,Binders and Binder Accessories,0.39\n4,R380,Clay Rozendal,483,1198.97,195.99,3.99,Nunavut,Telephones and Communication,0.58\n5,Holmes HEPA Air Purifier,Carlos Soltero,515,30.94,21.78,5.94,Nunavut,Appliances,0.5\n6,G.E. Longer-Life Indoor Recessed Floodlight Bulbs,Carlos Soltero,515,4.43,6.64,4.95,Nunavut,Office Furnishings,0.37\n7,\"Angle-D Binders with Locking Rings, Label Holders\",Carl Jackson,613,-54.04,7.3,7.72,Nunavut,Binders and Binder Accessories,0.38\n8,\"SAFCO Mobile Desk Side File, Wire Frame\",Carl Jackson,613,127.70,42.76,6.22,Nunavut,Storage & Organization,\n9,\"SAFCO Commercial Wire Shelving, Black\",Monica Federle,643,-695.26,138.14,35,Nunavut,Storage & Organization,\n10,Xerox 198,Dorothy Badders,678,-226.36,4.98,8.33,Nunavut,Paper,0.38\n11,Xerox 1980,Neola Schneider,807,-166.85,4.28,6.18,Nunavut,Paper,0.4\n12,Advantus Map Pennant Flags and Round Head Tacks,Neola Schneider,807,-14.33,3.95,2,Nunavut,Rubber Bands,0.53"
}
Code language: JSON / JSON with Comments (json)

Response

[
    {
        "Field1": 1,
        "Field2": "Eldon Base for stackable storage shelf, platinum",
        "Field3": "Muhammed MacIntyre",
        "Field4": "3",
        "Field5": -213.25,
        "Field6": 38.94,
        "Field7": "35",
        "Field8": "Nunavut",
        "Field9": "Storage & Organization",
        "Field10": "0.8"
    },
    {
        "Field1": 2,
        "Field2": "1.7 Cubic Foot Compact \"Cube\" Office Refrigerators",
        "Field3": "Barry French",
        "Field4": "293",
        "Field5": 457.81,
        "Field6": 208.16,
        "Field7": "68.02",
        "Field8": "Nunavut",
        "Field9": "Appliances",
        "Field10": "0.58"
    },
    {
        "Field1": 3,
        "Field2": "Cardinal Slant-D? Ring Binder, Heavy Gauge Vinyl",
        "Field3": "Barry French",
        "Field4": "293",
        "Field5": 46.71,
        "Field6": 8.69,
        "Field7": "2.99",
        "Field8": "Nunavut",
        "Field9": "Binders and Binder Accessories",
        "Field10": "0.39"
    },
    {
        "Field1": 4,
        "Field2": "R380",
        "Field3": "Clay Rozendal",
        "Field4": "483",
        "Field5": 1198.97,
        "Field6": 195.99,
        "Field7": "3.99",
        "Field8": "Nunavut",
        "Field9": "Telephones and Communication",
        "Field10": "0.58"
    },
    {
        "Field1": 5,
        "Field2": "Holmes HEPA Air Purifier",
        "Field3": "Carlos Soltero",
        "Field4": "515",
        "Field5": 30.94,
        "Field6": 21.78,
        "Field7": "5.94",
        "Field8": "Nunavut",
        "Field9": "Appliances",
        "Field10": "0.5"
    },
    {
        "Field1": 6,
        "Field2": "G.E. Longer-Life Indoor Recessed Floodlight Bulbs",
        "Field3": "Carlos Soltero",
        "Field4": "515",
        "Field5": 4.43,
        "Field6": 6.64,
        "Field7": "4.95",
        "Field8": "Nunavut",
        "Field9": "Office Furnishings",
        "Field10": "0.37"
    },
    {
        "Field1": 7,
        "Field2": "Angle-D Binders with Locking Rings, Label Holders",
        "Field3": "Carl Jackson",
        "Field4": "613",
        "Field5": -54.04,
        "Field6": 7.3,
        "Field7": "7.72",
        "Field8": "Nunavut",
        "Field9": "Binders and Binder Accessories",
        "Field10": "0.38"
    },
    {
        "Field1": 8,
        "Field2": "SAFCO Mobile Desk Side File, Wire Frame",
        "Field3": "Carl Jackson",
        "Field4": "613",
        "Field5": 127.7,
        "Field6": 42.76,
        "Field7": "6.22",
        "Field8": "Nunavut",
        "Field9": "Storage & Organization",
        "Field10": ""
    },
    {
        "Field1": 9,
        "Field2": "SAFCO Commercial Wire Shelving, Black",
        "Field3": "Monica Federle",
        "Field4": "643",
        "Field5": -695.26,
        "Field6": 138.14,
        "Field7": "35",
        "Field8": "Nunavut",
        "Field9": "Storage & Organization",
        "Field10": ""
    },
    {
        "Field1": 10,
        "Field2": "Xerox 198",
        "Field3": "Dorothy Badders",
        "Field4": "678",
        "Field5": -226.36,
        "Field6": 4.98,
        "Field7": "8.33",
        "Field8": "Nunavut",
        "Field9": "Paper",
        "Field10": "0.38"
    },
    {
        "Field1": 11,
        "Field2": "Xerox 1980",
        "Field3": "Neola Schneider",
        "Field4": "807",
        "Field5": -166.85,
        "Field6": 4.28,
        "Field7": "6.18",
        "Field8": "Nunavut",
        "Field9": "Paper",
        "Field10": "0.4"
    },
    {
        "Field1": 12,
        "Field2": "Advantus Map Pennant Flags and Round Head Tacks",
        "Field3": "Neola Schneider",
        "Field4": "807",
        "Field5": -14.33,
        "Field6": 3.95,
        "Field7": "2",
        "Field8": "Nunavut",
        "Field9": "Rubber Bands",
        "Field10": "0.53"
    }
]
Code language: JSON / JSON with Comments (json)