Module: HTTPX::Transcoder::JSON
- Defined in:
- lib/httpx/transcoder/json.rb
Defined Under Namespace
Classes: Encoder
Constant Summary collapse
- 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
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
permalink .decode(response) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/httpx/transcoder/json.rb', line 46 def decode(response) content_type = response.content_type.mime_type raise HTTPX::Error, "invalid json mime type (#{content_type})" unless JSON_REGEX.match?(content_type) method(:json_load) end |
permalink .encode(json) ⇒ Object
[View source]
42 43 44 |
# File 'lib/httpx/transcoder/json.rb', line 42 def encode(json) Encoder.new(json) end |
Instance Method Details
permalink #json_dump(*args) ⇒ Object
[View source]
57 |
# File 'lib/httpx/transcoder/json.rb', line 57 def json_dump(*args); MultiJson.dump(*args); end |
permalink #json_load(*args) ⇒ Object
[View source]
56 |
# File 'lib/httpx/transcoder/json.rb', line 56 def json_load(*args); MultiJson.load(*args); end |