我试图拉出字符串:
[{"name":"John Doe Jr."},{"name2":"John Doe"}] & {"name":"John Doe"}
来自以下 JSON 字符串中的有效负载:
{"to":"broadcast", "type":"50", "payload":[{"name":"John Doe Jr."},{"name2":"John Doe"}]}
{"to":"broadcast", "type":"50", "payload":{"name":"John Doe"}}
使用这个正则表达式代码:
Pattern pattern = Pattern.compile("\\{(.*?)\"payload\":\"(.*?)\"\\}\\}");
Matcher matcher = pattern.matcher(jsonString);
我收到 IllegalStateException: No successfull match so far
我的正则表达式有什么问题?
另外如何获得它找到的匹配数?
任何帮助,将不胜感激。