I have a String like
String input = "grant_type=client_credentials&scope=complexScope";
and I'd like to parse and then add these request parameters to a List of NameValuePair of Apache commons.
I have created this function, which technically works through String splits.
public static List<NameValuePair> stringToNameValuePair(String input) {
return Arrays.stream(input.split("&"))
.map(pair -> new NameValuePair(pair.split("=")[0], pair.split("=")[1]))
.collect(Collectors.toList());
}
which seems to do the job for simple things, but I wonder if there is something already built-in and more tested in java or in any known library.