Read Json file in JAVA with io.vertx.core.json library
The problem is that you're using the parser from another library and expecting to get an instance of io.vertx.core.json.JsonObject
. Instead, read your file containing your JSON text into a Java string. Note that you can do this using the IOUtils.toString(Reader)
method. Then, use the JsonObject
's constructor. For example, you could just use something similar to the following code:
String jsonStr = IOUtils.toString(new FileReader(myFileName));JsonObject jsonObj = new JsonObject(jsonStr);
Hope that helps!