From 92957d639b8eeaddb570725f7dc9dc9cc0080b0f Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 9 May 2014 10:29:54 +0200 Subject: Remove debug prints, add comments --- src/data/ValidatingJsonDeserializer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/data/ValidatingJsonDeserializer.java b/src/data/ValidatingJsonDeserializer.java index 8711f59..e38f68f 100644 --- a/src/data/ValidatingJsonDeserializer.java +++ b/src/data/ValidatingJsonDeserializer.java @@ -36,7 +36,6 @@ public class ValidatingJsonDeserializer implements JsonDeserializer { } JsonObject jsonObj = je.getAsJsonObject(); for (Field f : type.getDeclaredFields()) { - System.err.println("verif " + f.getName()); if (!jsonObj.has(f.getName())) { if (f.getAnnotation(Nullable.class) != null) { // null allowed, skip @@ -55,15 +54,18 @@ public class ValidatingJsonDeserializer implements JsonDeserializer { if (v != null) { Class type = f.getType(); if (type.isArray()) { + // the class expects an array, so the value must have one too. if (!je.isJsonArray()) { throw new JsonParseException("Not an array: " + f.getName()); } JsonArray ja = je.getAsJsonArray(); type = type.getComponentType(); + // for each array element, check if the object is valid. for (JsonElement arr_je : ja) { checkObject(arr_je, type); } } else { + // not an array, assume a verifiable object checkObject(je, type); } } -- cgit v1.2.1