diff options
author | ArghKevin <kagheli@student.sdccd.edu> | 2024-05-25 19:00:13 -0700 |
---|---|---|
committer | ArghKevin <kagheli@student.sdccd.edu> | 2024-05-25 19:00:13 -0700 |
commit | e1fa91563afe8ea44a715508249b1027e83f2bcb (patch) | |
tree | 4b595ee869c4b6b9a26c7495f0fafd514de7d641 /src/JSONReader.java | |
parent | a5efa4b382a8526ce541a910c9df53a195f5f919 (diff) |
Implmented interactive buttons.
Diffstat (limited to 'src/JSONReader.java')
-rw-r--r-- | src/JSONReader.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/JSONReader.java b/src/JSONReader.java index a4af8c9..4cc72ad 100644 --- a/src/JSONReader.java +++ b/src/JSONReader.java @@ -12,9 +12,10 @@ import java.io.*; * https://stackoverflow.com/questions/3880274/how-to-convert-the-object-to-string-in-java * https://stackoverflow.com/questions/8938498/get-the-index-of-a-pattern-in-a-string-using-regex * https://howtodoinjava.com/java/regex/start-end-of-string/ + * https://www.baeldung.com/java-remove-last-character-of-string * * Date: - * 2024-05-20 + * 2024-05-25 * * Purpose of class: * Read from and interpret JSON files. @@ -77,9 +78,15 @@ public class JSONReader extends Reader { /* This JSON is pretty-printed. */ int nl = json.indexOf("\n", start); - /* Extract substring. Remove any quotation marks and commas. */ - String substring = json.substring(start, nl); - return substring.replaceAll("[\",]", ""); + /* Extract substring. Remove any quotation marks. */ + String extract = json.substring(start, nl); + extract = extract.replaceAll("\"", ""); + + /* If the string ends with a comma, remove it. */ + if (extract.endsWith(",")) { + extract = extract.substring(0, extract.length() - 1); + } + return extract; } /** |