JsonUtil { public static void addAll( ArrayNode arr, Collection<String> list ) { if ( arr == null || list == null || list.isEmpty() ) { return; } for ( String s : list ) { arr.add( s ); } } private  JsonUtil(); static ObjectNode objectNode(); static ObjectNode createNode( String key, Object value ); static String toJson( Object value ); static T fromJson( String json, Class<T> type ); static byte[] toCbor( Object value ); static T fromCbor( byte data[], Class<T> type ); static void addAll( ArrayNode arr, Collection<String> list ); static final ObjectMapper MAPPER; }
@Test public void testAddAll() { ObjectNode json = JsonUtil.objectNode(); ArrayNode arr = json.putArray( "arr" ); Set<String> set = new HashSet<>(); set.add( "one" ); set.add( "two" ); JsonUtil.addAll( arr, set ); assertTrue( json.toString().contains( "arr" ) ); assertTrue( json.toString().contains( "one" ) ); assertTrue( json.toString().contains( "two" ) ); }