Sha256: 14763deebd8aa05b7df913b523ad97713b07ce0884cfe618142396e4a90668ed

Contents?: true

Size: 478 Bytes

Versions: 2

Compression:

Stored size: 478 Bytes

Contents

require 'json'

module JSONAPI
  module_function

  # Parse a JSON API document.
  #
  # @param document [Hash, String] the JSON API document.
  # @param options [Hash] options
  # @option options [Boolean] :id_optional (false) whether the resource
  #   objects in the primary data must have an id
  # @return [JSON::API::Document]
  def parse(document, options = {})
    hash = document.is_a?(Hash) ? document : JSON.parse(document)

    Document.new(hash, options)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jsonapi-0.1.1.beta2 lib/jsonapi/parse.rb
jsonapi-0.1.1.beta1 lib/jsonapi/parse.rb