Skip to content

Commit

Permalink
Code Simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
sathishk committed Feb 9, 2024
1 parent 0f080d3 commit 582939a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/main/java/com/techatpark/sjson/core/Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,24 +289,24 @@ private String getString() throws IOException {
// String with escape characters ?!
for (;;) {
switch (character) {
case 0, '\n', '\r':
throw new IllegalArgumentException(ILLEGAL_JSON_VALUE);
case '\\':
character = getCharacter(reader.read());
switch (character) {
case '"', '\'', '\\', '/' -> sb.append(character);
case 'u' -> sb.append((char) Integer
.parseInt(new String(next(LENGTH)),
RADIX));
case 'b' -> sb.append('\b');
case 't' -> sb.append('\t');
case 'n' -> sb.append('\n');
case 'f' -> sb.append('\f');
case 'r' -> sb.append('\r');
case 'u' -> sb.append((char) Integer
.parseInt(new String(next(LENGTH)),
RADIX));
case '"', '\'', '\\', '/' -> sb.append(character);
default -> throw new IllegalArgumentException(
ILLEGAL_JSON_VALUE);
}
break;
case 0, '\n', '\r':
throw new IllegalArgumentException(ILLEGAL_JSON_VALUE);
default:
if (character == '"') {
return sb.toString();
Expand Down Expand Up @@ -518,7 +518,6 @@ private char[] next(final int length) throws IOException {
* @throws IOException
*/
private Map<String, Object> getObject() throws IOException {

boolean eoo = endOfObject();
// This is Empty Object
if (eoo) {
Expand Down Expand Up @@ -561,10 +560,8 @@ private List<Object> getArray() throws IOException {
}
final List<Object> list = new ArrayList<>();
list.add(value);
boolean eoa = endOfArray();
while (!eoa) {
while (!endOfArray()) {
list.add(getValue());
eoa = endOfArray();
}
nextClean();
return list;
Expand Down

0 comments on commit 582939a

Please sign in to comment.