Azure/azure-sdk-for-ruby · jsonable.rb
ruby logo
def from_json(json, mapper = nil)
      mapper = self.class.mapper if mapper.nil?
      deserialize(mapper, json)
    end
Similar code snippets
1.
Match rating: 52.12% · See similar code snippets
ruby logo
def deserialize(json)
      self.account = deserialize_account(json.try_path('accountStatement', 'info'))
      self.transactions = deserialize_transactions(json.try_path('accountStatement', 'transactionList', 'transaction'))
      self
    end
2.
instructure/ims-lti · lti_model.rb
Match rating: 49.36% · 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
3.
Match rating: 47.15% · 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
4.
ScreenStaring/recharge-api · http_request.rb
Match rating: 44.48% · See similar code snippets
ruby logo
def parse_json(s)
      JSON.parse(s)
    rescue JSON::ParserError => e
      raise Error, "failed to parse JSON response: #{e}"
    end
5.
kost/nessus_rest-ruby · nessus_rest.rb
Match rating: 44.32% · See similar code snippets
ruby logo
def parse_json(body)
      buf = {}

      begin
        buf = JSON.parse(body)
      rescue JSON::ParserError
      end

      buf
    end
6.
soulim/oembed · parser.rb
Match rating: 44.11% · 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
7.
mailgun/mailgun-ruby · message_builder.rb
Match rating: 43.98% · See similar code snippets
ruby logo
def make_json(obj)
      return JSON.parse(obj).to_json if obj.is_a?(String)
      return obj.to_json if obj.is_a?(Hash)
      return JSON.generate(obj).to_json
    rescue
      raise Mailgun::ParameterError, 'Provided data could not be made into JSON. Try a JSON string or Hash.', obj
    end
8.
roobert/gclouder · helpers.rb
Match rating: 43.82% · See similar code snippets
ruby logo
def valid_json?(object)
      JSON.parse(object.to_s)
      return true
    rescue JSON::ParserError
      return false
    end
9.
xing/xing_api · response_handler.rb
Match rating: 43.46% · See similar code snippets
ruby logo
def parse_json(response)
      JSON.parse(response.body.to_s, symbolize_names: true)
    rescue JSON::ParserError
      { message: response.body.to_s }
    end
10.
cloudfoundry/bosh · instance.rb
Match rating: 43.37% · See similar code snippets
ruby logo
def spec
      return nil if spec_json.nil?

      begin
        result = JSON.parse(spec_json)
      rescue JSON::ParserError
        return 'error'
      end

      result
    end