accessing vendor-table.json from code

This commit is contained in:
iadgovuser58 2024-05-31 14:57:35 -04:00 committed by chubtub
parent 14b13ee8a8
commit b96b90fdd0
2 changed files with 29 additions and 1 deletions

View File

@ -101,6 +101,30 @@ public final class JsonUtils {
return jsonObject;
}
public static JsonObject getSpecificJsonObject(final String jsonFilename, final String elementName) {
// find the file and load it
return getSpecificJsonObject(jsonFilename, elementName, StandardCharsets.UTF_8);
}
public static JsonObject getSpecificJsonObject(final String jsonFilename,
final String elementName,
final Charset charset) {
// find the file and load it
JsonObject jsonObject = getJsonObject(jsonFilename, charset);
if (jsonObject != null && jsonObject.get(elementName) != null) {
return jsonObject.get(elementName).asObject();
}
return new JsonObject();
}
public static JsonObject getJsonObject(final String jsonFilename) {
return getJsonObject(jsonFilename, StandardCharsets.UTF_8);
}
public static JsonObject getJsonObject(final String jsonFilename, final Charset charset) {
// find the file and load it
JsonObject jsonObject = new JsonObject();

View File

@ -72,9 +72,13 @@ public class UefiGuid {
System.out.println("XXXX EMPTYYYYYYY, before trying to grab file from code");
uefiVendorRef = JsonUtils.getJsonObject("vendor-table2.json",
// uefiVendorRef = JsonUtils.getJsonObject("vendor-table2.json",
// StandardCharsets.UTF_8);
uefiVendorRef = JsonUtils.getSpecificJsonObject("vendor-table2.json", "VendorTable",
StandardCharsets.UTF_8);
// System.out.println("XXXX getClass: " + getClass());
// System.out.println("XXXX getClassResource: " + getClass().getResource("/vendor-table2.json"));
//