Sha256: a7c3e394e13262792037159a263fa56422baac2faf409f0265abc9c4402ea364

Contents?: true

Size: 363 Bytes

Versions: 2

Compression:

Stored size: 363 Bytes

Contents

require 'json'

module Servicy
  module Formats
    class JSON < Servicy::Format
      class << self
        def format(things)
          things.to_json
        end

        def unformat(things)
          return nil if things == "null"
          return ::JSON.parse(things) rescue ::JSON.parse("[#{things.inspect}]").first
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
servicy-0.0.6 lib/formats/json.rb
servicy-0.0.5 lib/formats/json.rb