@@ -58,29 +58,40 @@ public IDMEFObject()
58
58
properties .putAll (map );
59
59
}
60
60
61
- private static void putFields (IDMEFObject idmefObject , JsonNode node ) throws IDMEFException {
61
+ private static Object convertField (JsonNode value ) throws IDMEFException {
62
+ if (value .isInt ())
63
+ return value .asInt ();
64
+ else if (value .isTextual ())
65
+ return value .textValue ();
66
+ else if (value .isObject ())
67
+ return new IDMEFObject (value );
68
+ else if (value .isArray ()) {
69
+ List <Object > l = new ArrayList <>();
70
+
71
+ for (int i = 0 ; i < value .size (); i ++)
72
+ l .add (convertField (value .get (i )));
73
+
74
+ return l ;
75
+ } else
76
+ throw new IDMEFException ("Unhandled node type: " + value .getClass ().getName ());
77
+ }
78
+
79
+ private void putFields (JsonNode node ) throws IDMEFException {
62
80
Iterator <Map .Entry <String , JsonNode >> fields = node .fields ();
63
81
64
82
while (fields .hasNext ()) {
65
83
Map .Entry <String , JsonNode > field = fields .next ();
66
84
String key = field .getKey ();
67
85
JsonNode value = field .getValue ();
68
86
69
- if (value .isInt ())
70
- idmefObject .put (key , value .asInt ());
71
- else if (value .isTextual ())
72
- idmefObject .put (key , value .textValue ());
73
- else if (value .isObject ())
74
- idmefObject .put (key , new IDMEFObject (value ));
75
- else
76
- throw new IDMEFException ("Unhandled node type: " + value .getClass ().getName ());
87
+ put (key , convertField (value ));
77
88
}
78
89
}
79
90
80
91
IDMEFObject (JsonNode node ) throws IDMEFException {
81
92
this ();
82
93
83
- putFields (this , node );
94
+ putFields (node );
84
95
}
85
96
86
97
@ JsonAnyGetter
0 commit comments