From 2b1af32103ea1e6da44064d0bceed0fb82de8912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 26 Aug 2016 10:51:51 -0400 Subject: [PATCH] json::serialization: fix reading attributes from non-objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/json/serialization.nit | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/json/serialization.nit b/lib/json/serialization.nit index 8861e1938a..e26b8ec1d9 100644 --- a/lib/json/serialization.nit +++ b/lib/json/serialization.nit @@ -290,7 +290,14 @@ class JsonDeserializer redef fun deserialize_attribute(name, static_type) do - assert not path.is_empty # This is an internal error, abort + if path.is_empty then + # The was a parsing error or the root is not an object + if not root isa Error then + errors.add new Error("Deserialization Error: parsed JSON value is not an object.") + end + return null + end + var current = path.last if not current.keys.has(name) then