From 2cb004c6d0ce3c74b6fb552ea2137c5160e5802b Mon Sep 17 00:00:00 2001 From: coolneng Date: Sun, 10 Jan 2021 19:53:09 +0100 Subject: [PATCH] Fix JSON parser function --- src/main/java/org/RI/P2/Indexer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/RI/P2/Indexer.java b/src/main/java/org/RI/P2/Indexer.java index b6fc78a..563b390 100644 --- a/src/main/java/org/RI/P2/Indexer.java +++ b/src/main/java/org/RI/P2/Indexer.java @@ -45,10 +45,13 @@ public class Indexer { JSONArray parseJSONFile(String filePath) throws IOException, ParseException { InputStream jsonFile = getClass().getResourceAsStream(filePath); + JSONArray parseJSONFile(File file) throws IOException { + InputStream jsonFile = new FileInputStream(file); Reader readerJson = new InputStreamReader(jsonFile); - Object fileObjects = JSONValue.parse(readerJson); - JSONArray arrayObjects = (JSONArray) fileObjects; - return arrayObjects; + Object fileObject = JSONValue.parse(readerJson); + JSONArray arrayObject = new JSONArray(); + arrayObject.add(fileObject); + return arrayObject; } void openIndex() throws IOException {