public String toJson(Video video, String[] fields) throws Exception {
    var json = new StringBuilder().append("{");

    var i = 0;
    var fieldsLength = fields.length;
    while (i < fieldsLength) {
      json.append(getString(video, Video.class.getDeclaredField(fields[i])));
      if (i != fieldsLength - 1) {
        json.append(",");
      }
      i++;
    }
    json.append("}");
    return json.toString();
  }
@Test
  void shouldReturnJsonForSpecifiedFieldsInVideo() throws Exception {
    var fields = new String[]{"id", "title", "length"};
    var video = new Video(
        2, "Godzilla Resurgence", 120,
        "Action & drama movie|", "Hideaki Anno", "Japanese"
    );

    var jsonFieldResponse = mapper.toJson(video, fields);

    var expectedDetails = "{\"id\": 2,\"title\": \"Godzilla Resurgence\",\"length\": 120}";
    Assertions.assertEquals(expectedDetails, jsonFieldResponse);
  }