Skip to content

Commit

Permalink
json::serialization: fix reading attributes from non-objects
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Laferrière <[email protected]>
  • Loading branch information
xymus committed Aug 26, 2016
1 parent 27988ad commit 2b1af32
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/json/serialization.nit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2b1af32

Please sign in to comment.