Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/main/java/io/github/artemget/entrys/json/EJsonFile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.github.artemget.entrys.json;

import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;
import java.io.StringReader;
import io.github.artemget.entrys.ESafe;
import io.github.artemget.entrys.Entry;
import io.github.artemget.entrys.file.EFile;

public class EJsonFile extends ESafe<JsonObject> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be reasonable to add new ctor in https://github.com/ArtemGet/entrys/blob/main/src/main/java/io/github/artemget/entrys/json/EJsonObj.java instead of creating new class


public EJsonFile(String path) {
this(new EFile(path));
}

public EJsonFile(Entry<String> content) {
super(
() -> {
JsonReader jsonReader = Json.createReader(new StringReader(content.value()));
JsonObject object = jsonReader.readObject();
jsonReader.close();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using try catch with resources

return object;
}
);
}
}