Hello there..
any idea how to do it? I trying make a my own parser for non-quoted expressions for @{} json format.
(\w+):\s*([^ ,]+) Regex
Problem here are a any function what contains an ,, so the Matcher will also broke the function any idea for regex what can handle it?
Input:
{A: false, int: {_i}, json: {_json}, loc: location(10, 20, 30), mame: l(1,2)}
public void putAll(final String jsonString) {
int length = jsonString.length();
if (length > 1) {
String input = "{A: false, int: {_i}, json: {_json}, loc: location(10, 20, 30), mame: l(1,2)}";
Map<String, String> map = new HashMap<>();
Pattern p = Pattern.compile("(\\w+):\\s*([^,]+)");
Matcher m = p.matcher(input);
while (m.find()) {
map.put(m.group(1), m.group(2));
}
System.out.println(map);
}
}
Output: {A=false, loc=location(10, json={_json}, int={_i}, mame=l(1}