8 def self.legacy_load(s)
9 val = Psych.safe_load(s)
11 # If apiserver was downgraded to a YAML-only version after
12 # storing JSON in the database, the old code would have loaded
13 # the JSON document as a plain string, and then YAML-encoded
14 # it when saving it back to the database. It's too late now to
15 # make the old code behave better, but at least we can
16 # gracefully handle the mess it leaves in the database by
17 # double-decoding on the way out.
18 return SafeJSON.load(val)
27 elsif s[0] == first_json_char
29 elsif s[0..2] == "---"
32 raise "invalid serialized data #{s[0..5].inspect}"
37 class HashSerializer < Serializer
38 def self.first_json_char
47 class ArraySerializer < Serializer
48 def self.first_json_char