json file
persion.json:
{
"personname": "Boo",
"age": 32,
"numbers" : [1, 2, 3],
"alive": true
}
java code
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.json.JSONObject;
void main() {
try {
final String content = new String(Files.readAllBytes(Paths.get("person.json")));
JSONObject jsonObj = new JSONObject(content);
System.out.println(jsonObj.get("personname"));
} catch (IOException e) {
e.printStackTrace();
}
}