I have an arrayList of strings, for example:
ArrayList<String> result = new ArrayList<String>() ;
result.add("Name.A");
result.add("Name.B");
result.add("Name.C");
result.add("Type.D");
result.add("Type.E");
result.add("Type.F");
Now I need to convert it into HashMap with one key(before dot) to multiple values(after dot).
Like this: Map<String,String[]> map = new HashMap<>();
map(Name= A,B,C)
map(Type= D,E,F)
Don't know how to do it. Any help would be appreciated
Response response
= given().
relaxedHTTPSValidation().
accept(ContentType.JSON).
when().
urlEncodingEnabled(true).
get(uri).
then().
extract().response();
List<String> actual = response.jsonPath().getList("RESPONSE.A_VALUE");
Map<String, String[]> map = new HashMap<>();
for (String pair : actual) //iterate over the pairs
{
if (pair.contains(".")) {
String[] pair_values = pair.split("\\.");
map.put(pair_values[0].trim(), pair_values[1].trim());
}
}