CSV to JSON Converter API - Ruby Gem
CSV to JSON Converter is a powerful tool for converting CSV data into JSON format. It supports custom delimiters, header detection, and handles quoted fields properly.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_csvtojson'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_csvtojson
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_csvtojson'
# Initialize the client
client = APIVerve::Csvtojson::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
csv: "name,age,city
John Doe,30,New York
Jane Smith,25,Los Angeles",
delimiter: ",",
has_header: true
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ csv: "name,age,city
John Doe,30,New York
Jane Smith,25,Los Angeles", delimiter: ",", has_header: true })
puts response["data"]
rescue APIVerve::Csvtojson::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Csvtojson::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Csvtojson::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"row_count": 2,
"column_count": 3,
"columns": [
"name",
"age",
"city"
],
"inferredTypes": {
"name": "string",
"age": "integer",
"city": "string"
},
"json": [
{
"name": "John Doe",
"age": "30",
"city": "New York"
},
{
"name": "Jane Smith",
"age": "25",
"city": "Los Angeles"
}
]
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/csvtojson?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.