def deserialize(json)
      self.account = deserialize_account(json.try_path('accountStatement', 'info'))
      self.transactions = deserialize_transactions(json.try_path('accountStatement', 'transactionList', 'transaction'))
      self
    end
Similar code snippets
1.
Match rating: 55.18% · See similar code snippets
ruby logo
def deserialize_account(account_json)
      FioAPI::Account.new(
        account_id:       account_json.try_path('accountId'),
        bank_id:          account_json.try_path('bankId'),
        currency:         account_json.try_path('currency'),
        iban:             account_json.try_path('iban'),
        bic:              account_json.try_path('bic'),
        opening_balance:  account_json.try_path('openingBalance'),
        closing_balance:  account_json.try_path('closingBalance'),
        date_start:       account_json.try_path('dateStart'),
        date_end:         account_json.try_path('dateEnd'),
        year_list:        account_json.try_path('yearList'),
        id_list:          account_json.try_path('idList'),
        id_from:          account_json.try_path('idFrom'),
        id_to:            account_json.try_path('idTo'),
        id_last_download: account_json.try_path('idLastDownload')
      )
    end
2.
Azure/azure-sdk-for-ruby · jsonable.rb
Match rating: 52.12% · See similar code snippets
ruby logo
def from_json(json, mapper = nil)
      mapper = self.class.mapper if mapper.nil?
      deserialize(mapper, json)
    end
3.
Match rating: 50.55% · See similar code snippets
ruby logo
def deserialize_import(response_json)
      return FioAPI::Payments::Status.new(error_code: 500) unless response_json
      FioAPI::Payments::Status.new(
        error_code: response_json.try_path('errorCode').to_i,
        error_message: response_json.try_path('message').to_s,
        id_instruction: response_json.try_path('idInstruction').to_i,
        sum_credit: response_json.try_path('sums', 'sum', 'sumCredit').to_f,
        sum_debet: response_json.try_path('sums', 'sum', 'sumDebet').to_f
      )
    end
4.
pfeiffer/epay · subscription.rb
Match rating: 48.05% · See similar code snippets
ruby logo
def transactions
      return [] unless data['transactionList'].present?
      
      # transactionList can be a hash or an array
      Array.wrap(data['transactionList']['TransactionInformationType']).collect do |transaction_data|
        Transaction.new(transaction_data['transactionid'].to_i, transaction_data)
      end
    end
5.
soulim/oembed · parser.rb
Match rating: 45.05% · See similar code snippets
ruby logo
def json(body)
      begin
        JSON.parse(body)
      rescue JSON::JSONError => e
        raise Oembed::ParserError.new(e), 'JSON parser error'
      end
    end
6.
chanks/que · listener.rb
Match rating: 44.94% · See similar code snippets
ruby logo
def parse_payload(payload)
      Que.deserialize_json(payload)
    rescue JSON::ParserError => e
      Que.notify_error_async(e)
      nil
    end
7.
instructure/ims-lti · lti_model.rb
Match rating: 44.8% · See similar code snippets
ruby logo
def from_json(json)
      json = json.to_json unless json.is_a?(String)
      begin
        data = JSON.parse(json)
      rescue
        data = JSON.parse(URI.unescape(json))
      end

      if data.is_a? Array
        data.map { |hash| self.class.from_json(hash.to_json) }
      else
        process_json_hash(data)
      end
    end
8.
travis-ci/travis-core · formats.rb
Match rating: 44.71% · See similar code snippets
ruby logo
def normalize_json(json)
      json = json.to_json unless json.is_a?(String)
      JSON.parse(json)
    end
9.
westlakedesign/auth_net_receiver · raw_transaction.rb
Match rating: 43.82% · See similar code snippets
ruby logo
def json_data
      begin
        return JSON.parse(self.data)
      rescue JSON::ParserError, TypeError => e
        logger.warn "Error while parsing raw transaction data: #{e.message}"
        return {}
      end
    end
10.
Katello/katello_api · base.rb
Match rating: 42.98% · See similar code snippets
ruby logo
def process_data(response)
      data = begin
               JSON.parse(response.body)
             rescue JSON::ParserError
               response.body
             end
      return data, response
    end