cast_json: enforce param type at compile time

This commit is contained in:
Samantaz Fox 2022-12-01 00:07:22 +01:00
parent 11813ae363
commit c6cede69e6

View File

@ -468,9 +468,7 @@ module Protodec
Any.new(raw.clone) Any.new(raw.clone)
end end
def self.cast_json(object) def self.cast_json(object : Hash)
raise "Invalid type" if !object.is_a?(Hash)
JSON::Any.new(object.transform_values do |value| JSON::Any.new(object.transform_values do |value|
case value case value
when .is_a?(Hash) when .is_a?(Hash)