module HTTPX::Transcoder::JSON

  1. lib/httpx/transcoder/json.rb

Methods

Public Instance

  1. decode
  2. encode
  3. json_dump
  4. json_load

Classes and Modules

  1. HTTPX::Transcoder::JSON::Encoder

Constants

JSON_REGEX = %r{ \b application/ # optional vendor specific type (?: # token as per https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6 [!#$%&'*+\-.^_`|~0-9a-z]+ # literal plus sign \+ )? json \b }ix.freeze  

Public Instance methods

decode(response)
[show source]
   # File lib/httpx/transcoder/json.rb
46 def decode(response)
47   content_type = response.content_type.mime_type
48 
49   raise HTTPX::Error, "invalid json mime type (#{content_type})" unless JSON_REGEX.match?(content_type)
50 
51   method(:json_load)
52 end
encode(json)
[show source]
   # File lib/httpx/transcoder/json.rb
42 def encode(json)
43   Encoder.new(json)
44 end
json_dump(*args)
[show source]
   # File lib/httpx/transcoder/json.rb
57 def json_dump(*args); MultiJson.dump(*args); end
json_load(*args)
[show source]
   # File lib/httpx/transcoder/json.rb
56 def json_load(*args); MultiJson.load(*args); end