I get following strings from a server, only separated by spaces. (Line breaks are just due to readability, "XX is a placeholder and can vary in length. also the length of the things in square brackets can vary in length.
String 1:
status:ok [XXX][a=XXX b=XXX c=XXX d=XXX e=0 f=XXX g=XXX h=XXX i=XXX j=XXX
k=XXX l=XXX m=XXX n=[[XXX][XXX]] p=[[XXX][XXX][XXX][XXX][XXX][XXX][XXX]]]
end:end
String 2:
status:ok [XXX][a=XXX b=XXX c=XXX d=XXX d2=XXX e=XXX f=XXX g=XXX h=XXX i=XXX j=XXX
k=XXX l=XXX m=XXX n=[[XXX][XXX]] p=[[XXX][XXX][XXX][XXX][XXX][XXX][XXX]]]
end:end
All parts in square brackets "[]" can contain more or less of "[]"-elements and words inside a inner "[]" can vary in length. I need those a,b,c,d,e etc. in a HashMap, but before i can do that i need to parse it somehow.
How can i parse this string efficiently in Java?
I have searched and found lots of websites and threads where people suggested something called "key value parsing" apart from "Regex parsing", but unfortunately information on "key value parsing" is sparse.
EDIT: In the end I want to store those values in a Hashmap like this:
HashMap<String,Object> myHashMap = new HashMap();
myHashMap.put(a, XXX);
....
myHashMap.put(p,array-of-all-[XXX]);
i need to parse it somehow.-> How exactly is thatsomehow?