File: json_parser.rb

package info (click to toggle)
ruby-prometheus-client-mmap 1.2.9-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 700 kB
  • sloc: ruby: 3,149; sh: 54; makefile: 21
file content (23 lines) | stat: -rw-r--r-- 449 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'json'

module Prometheus
  module Client
    module Helper
      module JsonParser
        class << self
          if defined?(Oj)
            def load(s)
              Oj.load(s)
            rescue Oj::ParseError, EncodingError => e
              raise JSON::ParserError.new(e.message)
            end
          else
            def load(s)
              JSON.parse(s)
            end
          end
        end
      end
    end
  end
end