JSON to JSONP API - Ruby Gem

JSON to JSONP is a simple tool for converting JSON data into JSONP format. It returns the converted JSONP data.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_jsontojsonp'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_jsontojsonp

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_jsontojsonp'

# Initialize the client
client = APIVerve::Jsontojsonp::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({
  callback: "callbackFunction",
  json: [object Object]
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ callback: "callbackFunction", json: [object Object] })
  puts response["data"]
rescue APIVerve::Jsontojsonp::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Jsontojsonp::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Jsontojsonp::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "callback": "callbackFunction",
    "jsonp": "callbackFunction({\"menu\":{\"id\":\"file\",\"value\":\"File\",\"popup\":false}});"
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.