@Udf
  public <T> String toJsonString(@UdfParameter final T input) {
    return toJson(input);
  }
@Test
  public void shouldSerializeNestedArrayOfStructs() {
    // When:
    final Schema mapSchema = SchemaBuilder.map(Schema.INT32_SCHEMA, Schema.STRING_SCHEMA);
    final String structkey = "json_key";
    final String structValue = "json_value";
    final Schema schema = SchemaBuilder.struct()
        .field(structkey, Schema.INT32_SCHEMA)
        .field(structValue, mapSchema)
        .build();
    final Struct struct = new Struct(schema);
    struct.put(structkey, 1);
    struct.put(structValue, new HashMap<Integer, String>() {{
        put(2, "c");
        put(4, "d");
      }}
    );
    final String result = udf.toJsonString(Collections.singletonList(struct));

    // Then:
    assertEquals("[{\"json_key\":1,\"json_value\":{\"2\":\"c\",\"4\":\"d\"}}]", result);
  }