IMPORTANT: For a .NET Framework version of this repo, please see joelbyford/CSVtoJSON instead (which was forked from jeffhollan/CSVtoJSON).
Simple REST API which converts a delimited payload (via HTTP POST) to a JSON object.
Optional querystring parameter to allow consumers to specify the delimiter being used in the text file and allows for other delimiters (such as | or ;). Usage is:
mydomain.com/myservice/?delimiter=|
If no delimiter parameter is provided, comma is assumed.
Example test through Postman or REST plugin in VSCode:
POST https://SOME-WEBSITE-URL/csvtojson
Content-Type: text/csv
this,is,a,test
1,2,3,4
a,b,c,d
Results should appear similar to the following:
{
"rows": [
{
"this": "1",
"is": "2",
"a": "3",
"test": "4"
},
{
"this": "a",
"is": "b",
"a": "c",
"test": "d"
}
]
}
Additional examples can be found in the test
folder.
If you are deploying to Azure, the following are steps you can use to re-use/leverage the existing CI/CD pipeline defined in the GitHub Actions YML files which already exist in this repo:
- Create your App Service in an Azure Subscription
- Create 2 additional Deployment Slots (one for testing and one for staging)
- Define an OpenID Connect credential for GitHub to leverage.
- Fork the Repo (this will probably trigger a GitHub Action which will fail . . .don't worry. . .it's not configured yet).
- Add the following Secrets in your forked repo:
Used for OpenID Connect Authentication:
- AZURE_CLIENTID (See OpenID Connect Instructions)
- AZURE_TENANTID (See OpenID Connect Instructions)
- AZURE_SUBSCRIPTIONID (See OpenID Connect Instructions)
General Parameters kept secret so not giving away too many details about your deployment in a public repo:
- APP_NAME - the name of your AppService in Azure
- APP_RG - the resource group name where your AppService lives
Automated Smoke Testing (currently uses PyTest) parameters:
- TEST_URL - the URL for accessing your AppService test slot in Azure (e.g. "https://{mysite}-test.azurewebsites.net/" if you named your slot "test")
- STAGING_URL - the URL for accessing your AppService staging slot in Azure (e.g. "https://{mysite}-staging.azurewebsites.net/" if you named your slot "staging").
Added the ability to use Basic Authentication with the API. In order to leverage this functionality, please use the appsettings.json
file to enable basic authentication, provide your "realm" (typically your API's url), and point to the json file where your users are listed (defaults to the provided authorizedUsers.json
):
"AppSettings" : {
"BasicAuth" : {
"Enabled" : false, # change this to true
"Realm" : "example-realm.com", # change this to your API's Domain
"UsersJson" : "authorizedUsers.json" # change this (if necessary) to the json file with authorized users
}
}
The Authorized Users are simply stored in a json file in the following format:
{
"testUser" : "testPassword",
"devUser" : "devPassword"
}
This is a psudo-fork dotnet core implementation of the previous .NET Framework CSVtoJSON repo provided by Jeff Hollan.
Additionally, many thanks go to Josh Close for his CsvHelper package used in this project.