@@ -263,22 +263,18 @@ package body JSON.Types is
263263
264264 procedure Append (Object : in out JSON_Value; Value : JSON_Value) is
265265 begin
266- if Object.Kind = Array_Kind then
267- declare
268- Length : constant Natural
269- := Natural (Object.Allocator.Array_Levels (Object.Depth).Length);
270- begin
271- -- Assert that Object is the last array in a particular level
272- -- so that its elements form a continuous array
273- pragma Assert (Length = Object.Offset + Object.Length);
274- end ;
275-
276- Object.Allocator.Array_Levels (Object.Depth).Append
277- (Array_Value'(Kind => Value.Kind, Value => Value));
278- Object.Length := Object.Length + 1 ;
279- else
280- raise Invalid_Type_Error with " Value not an array" ;
281- end if ;
266+ declare
267+ Length : constant Natural
268+ := Natural (Object.Allocator.Array_Levels (Object.Depth).Length);
269+ begin
270+ -- Assert that Object is the last array in a particular level
271+ -- so that its elements form a continuous array
272+ pragma Assert (Length = Object.Offset + Object.Length);
273+ end ;
274+
275+ Object.Allocator.Array_Levels (Object.Depth).Append
276+ (Array_Value'(Kind => Value.Kind, Value => Value));
277+ Object.Length := Object.Length + 1 ;
282278 end Append ;
283279
284280 procedure Insert
@@ -287,27 +283,23 @@ package body JSON.Types is
287283 Value : JSON_Value;
288284 Check_Duplicate_Keys : Boolean) is
289285 begin
290- if Object.Kind = Object_Kind then
291- if Check_Duplicate_Keys and then Object.Contains (Key.Value) then
292- raise Constraint_Error with " JSON object already has key '" & Key.Value & " '" ;
293- end if ;
294-
295- declare
296- Length : constant Natural
297- := Natural (Object.Allocator.Object_Levels (Object.Depth).Length);
298- begin
299- -- Assert that Object is the last object in a particular level
300- -- so that its key-value pairs form a continuous array
301- pragma Assert (Length = Object.Offset + Object.Length);
302- end ;
303- pragma Assert (Key.Kind = String_Kind);
304-
305- Object.Allocator.Object_Levels (Object.Depth).Append
306- (Key_Value_Pair'(Kind => Value.Kind, Key => Key, Element => Value));
307- Object.Length := Object.Length + 1 ;
308- else
309- raise Invalid_Type_Error with " Value not an object" ;
286+ if Check_Duplicate_Keys and then Object.Contains (Key.Value) then
287+ raise Constraint_Error with " JSON object already has key '" & Key.Value & " '" ;
310288 end if ;
289+
290+ declare
291+ Length : constant Natural
292+ := Natural (Object.Allocator.Object_Levels (Object.Depth).Length);
293+ begin
294+ -- Assert that Object is the last object in a particular level
295+ -- so that its key-value pairs form a continuous array
296+ pragma Assert (Length = Object.Offset + Object.Length);
297+ end ;
298+ pragma Assert (Key.Kind = String_Kind);
299+
300+ Object.Allocator.Object_Levels (Object.Depth).Append
301+ (Key_Value_Pair'(Kind => Value.Kind, Key => Key, Element => Value));
302+ Object.Length := Object.Length + 1 ;
311303 end Insert ;
312304
313305 -- ---------------------------------------------------------------------------
0 commit comments