Sha256: 2c67803174ab4bc580c1019517098dae53dd64db28331e2cb0ba78d2ed3a904c
Contents?: true
Size: 923 Bytes
Versions: 18
Compression:
Stored size: 923 Bytes
Contents
# frozen_string_literal: true module Karafka # Module for all supported by default serialization and deserialization ways module Serialization # Namespace for json ser/der module Json # Default Karafka Json deserializer for loading JSON data class Deserializer # @param params [Karafka::Params::Params] Full params object that we want to deserialize # @return [Hash] hash with deserialized JSON data # @example # params = { # 'payload' => "{\"a\":1}", # 'topic' => 'my-topic', # 'headers' => { 'message_type' => :test } # } # Deserializer.call(params) #=> { 'a' => 1 } def call(params) params.raw_payload.nil? ? nil : ::JSON.parse(params.raw_payload) rescue ::JSON::ParserError => e raise ::Karafka::Errors::DeserializationError, e end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems