title: Getting items from JsonArray dynamically no matter what is the type using GSON
body: <p>I got this JsonArray:</p>
  
  <pre><code>   "jokes": [
        {
          "description": "Knock Knock joke of the day!",
          "language": "en",
          "background": "",
          "category": "knock-knock",
          "date": "2019-12-02",
          "joke": {
            "title": "Knock Knock - Raoul who?",
            "lang": "en",
            "length": "64",
            "clean": "1",
            "racial": "0",
            "id": "GcLEyRMil3Od8VaaNtGo5QeF",
            "text": "Knock Knock\r\nWho's there?\r\nRaoul!\r\nRaoul who?\r\nRaoul of law!\r\n\r\n"
          }
        }
      ],
      "copyright": "2019-20 https://jokes.one"
    }
  }
  </code></pre>
  
  <p>I want to be able to retrieve any item from the json array with no importance for the data type ,
  for example if I want to get JsonObject <code>joke</code> I implemented this function:</p>
  
  <pre><code>public static JsonObject getJsonObjectFromJsonArray(int index, String fieldName, JsonArray jsonArray) {
          return jsonArray.get(index).getAsJsonObject().get(fieldName).getAsJsonObject();
      }
  </code></pre>
  
  <p>and if I want to retrieve json element which is string I implmeneted this function:</p>
  
  <pre><code>   public static String getItemStringFromJsonArray(int index, String fieldName, JsonArray jsonArray){
          return jsonArray.get(index).getAsJsonObject().get(fieldName).getAsString();
      }
  </code></pre>
  
  <p>those two last methods looks the same but return different data types , how can I make it generic?</p>