Commit 7d57c135 authored by Robert May's avatar Robert May

Remove :oj_json feature flag

Removes the :oj_json feature flag and defaults to the
OJ gem for most JSON requirements.
parent cceffe5e
---
name: oj_json
introduced_by_url:
rollout_issue_url:
group:
type: development
default_enabled: true
...@@ -67,15 +67,6 @@ module Gitlab ...@@ -67,15 +67,6 @@ module Gitlab
::JSON.pretty_generate(object, opts) ::JSON.pretty_generate(object, opts)
end 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 private
# Convert JSON string into Ruby through toggleable adapters. # Convert JSON string into Ruby through toggleable adapters.
...@@ -91,11 +82,7 @@ module Gitlab ...@@ -91,11 +82,7 @@ module Gitlab
def adapter_load(string, *args, **opts) def adapter_load(string, *args, **opts)
opts = standardize_opts(opts) opts = standardize_opts(opts)
if enable_oj? Oj.load(string, opts)
Oj.load(string, opts)
else
::JSON.parse(string, opts)
end
rescue Oj::ParseError, Encoding::UndefinedConversionError => ex rescue Oj::ParseError, Encoding::UndefinedConversionError => ex
raise parser_error.new(ex) raise parser_error.new(ex)
end end
...@@ -120,11 +107,7 @@ module Gitlab ...@@ -120,11 +107,7 @@ module Gitlab
# #
# @return [String] # @return [String]
def adapter_dump(object, *args, **opts) def adapter_dump(object, *args, **opts)
if enable_oj? Oj.dump(object, opts)
Oj.dump(object, opts)
else
::JSON.dump(object, *args)
end
end end
# Generates JSON for an object but with fewer options, using toggleable adapters. # Generates JSON for an object but with fewer options, using toggleable adapters.
...@@ -135,11 +118,7 @@ module Gitlab ...@@ -135,11 +118,7 @@ module Gitlab
def adapter_generate(object, opts = {}) def adapter_generate(object, opts = {})
opts = standardize_opts(opts) opts = standardize_opts(opts)
if enable_oj? Oj.generate(object, opts)
Oj.generate(object, opts)
else
::JSON.generate(object, opts)
end
end end
# Take a JSON standard options hash and standardize it to work across adapters # Take a JSON standard options hash and standardize it to work across adapters
...@@ -149,11 +128,8 @@ module Gitlab ...@@ -149,11 +128,8 @@ module Gitlab
# @return [Hash] # @return [Hash]
def standardize_opts(opts) def standardize_opts(opts)
opts ||= {} opts ||= {}
opts[:mode] = :rails
if enable_oj? opts[:symbol_keys] = opts[:symbolize_keys] || opts[:symbolize_names]
opts[:mode] = :rails
opts[:symbol_keys] = opts[:symbolize_keys] || opts[:symbolize_names]
end
opts opts
end end
...@@ -213,7 +189,7 @@ module Gitlab ...@@ -213,7 +189,7 @@ module Gitlab
# @param object [Object] # @param object [Object]
# @return [String] # @return [String]
def self.call(object, env = nil) 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) Gitlab::Json.dump(object)
else else
Grape::Formatter::Json.call(object, env) 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