module SimpleCov::JSON

Public Instance Methods

dump(string) click to toggle source
# File lib/simplecov/json.rb, line 14
def dump(string)
  if defined? ::JSON
    ::JSON.pretty_generate(string)
  else
    # Detect and use available MultiJson API - it changed in v1.3
    if MultiJson.respond_to?(:adapter)
      MultiJson.dump(string)
    else
      MultiJson.encode(string)
    end
  end
end
parse(json) click to toggle source
# File lib/simplecov/json.rb, line 5
def parse(json)
  # Detect and use available MultiJson API - it changed in v1.3
  if MultiJson.respond_to?(:adapter)
    MultiJson.load(json)
  else
    MultiJson.decode(json)
  end
end