Skip to content

Commit 23756aa

Browse files
authored
Merge pull request #8917 from jcharaoui/oj-bigdecimal
(PUP-11620) Avoid sending malformed PuppetDB reports with Oj
2 parents 52d51c3 + 930a1ef commit 23756aa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/puppet/util/json.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ def self.load_file(filename, options = {})
4949
def self.load(string, options = {})
5050
if defined? MultiJson
5151
begin
52-
# This ensures that JrJackson will parse very large or very small
52+
# This ensures that JrJackson and Oj will parse very large or very small
5353
# numbers as floats rather than BigDecimals, which are serialized as
5454
# strings by the built-in JSON gem and therefore can cause schema errors,
5555
# for example, when we are rendering reports to JSON using `to_pson` in
5656
# PuppetDB.
57-
if MultiJson.adapter.name == "MultiJson::Adapters::JrJackson"
57+
case MultiJson.adapter.name
58+
when "MultiJson::Adapters::JrJackson"
5859
options[:use_bigdecimal] = false
60+
when "MultiJson::Adapters::Oj"
61+
options[:bigdecimal_load] = :float
5962
end
6063

6164
MultiJson.load(string, options)

0 commit comments

Comments
 (0)