Commit b1f75a22 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'default-oj' into 'master'

Remove :oj_json feature flag

See merge request gitlab-org/gitlab!46012
parents cb4ec474 7d57c135
---
name: oj_json
introduced_by_url:
rollout_issue_url:
group:
type: development
default_enabled: true
......@@ -67,15 +67,6 @@ module Gitlab
::JSON.pretty_generate(object, opts)
end
# Feature detection for using Oj instead of the `json` gem.
#
# @return [Boolean]
def enable_oj?
return false unless feature_table_exists?
Feature.enabled?(:oj_json, default_enabled: true)
end
private
# Convert JSON string into Ruby through toggleable adapters.
......@@ -91,11 +82,7 @@ module Gitlab
def adapter_load(string, *args, **opts)
opts = standardize_opts(opts)
if enable_oj?
Oj.load(string, opts)
else
::JSON.parse(string, opts)
end
Oj.load(string, opts)
rescue Oj::ParseError, Encoding::UndefinedConversionError => ex
raise parser_error.new(ex)
end
......@@ -120,11 +107,7 @@ module Gitlab
#
# @return [String]
def adapter_dump(object, *args, **opts)
if enable_oj?
Oj.dump(object, opts)
else
::JSON.dump(object, *args)
end
Oj.dump(object, opts)
end
# Generates JSON for an object but with fewer options, using toggleable adapters.
......@@ -135,11 +118,7 @@ module Gitlab
def adapter_generate(object, opts = {})
opts = standardize_opts(opts)
if enable_oj?
Oj.generate(object, opts)
else
::JSON.generate(object, opts)
end
Oj.generate(object, opts)
end
# Take a JSON standard options hash and standardize it to work across adapters
......@@ -149,11 +128,8 @@ module Gitlab
# @return [Hash]
def standardize_opts(opts)
opts ||= {}
if enable_oj?
opts[:mode] = :rails
opts[:symbol_keys] = opts[:symbolize_keys] || opts[:symbolize_names]
end
opts[:mode] = :rails
opts[:symbol_keys] = opts[:symbolize_keys] || opts[:symbolize_names]
opts
end
......@@ -213,7 +189,7 @@ module Gitlab
# @param object [Object]
# @return [String]
def self.call(object, env = nil)
if Gitlab::Json.enable_oj? && Feature.enabled?(:grape_gitlab_json, default_enabled: true)
if Feature.enabled?(:grape_gitlab_json, default_enabled: true)
Gitlab::Json.dump(object)
else
Grape::Formatter::Json.call(object, env)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment