Skip to content

Commit 116998f

Browse files
committed
Replace PSON with JSON
1 parent 6723dec commit 116998f

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/puppet/parser/functions/load_module_metadata.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ module Puppet::Parser::Functions
2424

2525
metadata_exists = File.exists?(metadata_json) # rubocop:disable Lint/DeprecatedClassMethods : Changing to .exist? breaks the code
2626
if metadata_exists
27-
metadata = PSON.load(File.read(metadata_json))
27+
metadata = if Puppet::Util::Package.versioncmp(Puppet.version, '8.0.0').negative?
28+
PSON.load(File.read(metadata_json))
29+
else
30+
JSON.parse(File.read(metadata_json))
31+
end
2832
else
2933
metadata = {}
3034
raise(Puppet::ParseError, "load_module_metadata(): No metadata.json file for module #{mod}") unless allow_empty_metadata

lib/puppet/parser/functions/loadjson.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,18 @@ module Puppet::Parser::Functions
4949
warning("Can't load '#{url}' HTTP Error Code: '#{res.status[0]}'")
5050
args[1]
5151
end
52-
PSON.load(contents) || args[1]
52+
if Puppet::Util::Package.versioncmp(Puppet.version, '8.0.0').negative?
53+
PSON.load(contents) || args[1]
54+
else
55+
JSON.parse(contents) || args[1]
56+
end
5357
elsif File.exists?(args[0]) # rubocop:disable Lint/DeprecatedClassMethods : Changing to .exist? breaks the code
5458
content = File.read(args[0])
55-
PSON.load(content) || args[1]
59+
if Puppet::Util::Package.versioncmp(Puppet.version, '8.0.0').negative?
60+
PSON.load(content) || args[1]
61+
else
62+
JSON.parse(content) || args[1]
63+
end
5664
else
5765
warning("Can't load '#{args[0]}' File does not exist!")
5866
args[1]

0 commit comments

Comments
 (0)