Skip to content

Instantly share code, notes, and snippets.

@vixduong
Created August 18, 2022 13:27
Show Gist options
  • Save vixduong/339a932105e4fb1d09b8686e34f57491 to your computer and use it in GitHub Desktop.
Save vixduong/339a932105e4fb1d09b8686e34f57491 to your computer and use it in GitHub Desktop.
StringBuilder sb = new StringBuilder();
Matcher matcher = Pattern.compile("(\")(.*?)(\"\s*:)").matcher(json);
while (matcher.find()) {
matcher.appendReplacement(sb, String.join("",
matcher.group(1),
matcher.group(2).substring(0, 1).toUpperCase(),
matcher.group(2).substring(1),
matcher.group(3))
);
}
matcher.appendTail(sb);
System.out.printf("%s\n", sb.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment