class Catalog::Json
Public Instance Methods
from_json(text)
click to toggle source
# File lib/puppet/indirector/catalog/json.rb 8 def from_json(text) 9 utf8 = text.force_encoding(Encoding::UTF_8) 10 11 if utf8.valid_encoding? 12 model.convert_from(json_format, utf8) 13 else 14 Puppet.info(_("Unable to deserialize catalog from json, retrying with pson")) 15 model.convert_from('pson', text.force_encoding(Encoding::BINARY)) 16 end 17 end
to_json(object)
click to toggle source
# File lib/puppet/indirector/catalog/json.rb 19 def to_json(object) 20 object.render(json_format) 21 rescue Puppet::Network::FormatHandler::FormatError => err 22 if Puppet[:allow_pson_serialization] 23 Puppet.info(_("Unable to serialize catalog to json, retrying with pson. PSON is deprecated and will be removed in a future release")) 24 Puppet.log_exception(err, err.message, level: :debug) 25 object.render('pson').force_encoding(Encoding::BINARY) 26 else 27 Puppet.info(_("Unable to serialize catalog to json, no other acceptable format")) 28 Puppet.log_exception(err, err.message, level: :err) 29 end 30 end
Private Instance Methods
json_format()
click to toggle source
# File lib/puppet/indirector/catalog/json.rb 34 def json_format 35 if Puppet[:rich_data] 36 'rich_data_json' 37 else 38 'json' 39 end 40 end