public void transform(String fileName) throws IOException { String content = new
String(Files.readAllBytes(Paths.get(fileName)), StandardCharsets.UTF_8); org.json.JSONObject json = new org.json.JSONObject(content); log.info(org.json.XML.toString(json)); }
What you seem to want to achieve is:
1. Open a JSON file as a string; 2. Convert this string to a JSON object; 3. Write this JSON object as XML to a log output (?)
This would be the XQuery way to do it:
let $content := file:read-text('x.json') let $json := json:parse($content) return admin:write-log($json)
If you address the BaseX Java code, you can work with different abstraction levels. Maybe it’s already sufficient if you evaluate the upper XQuery string as command:
Context ctx = new Context(); String query = "let $content..."; XQuery cmd = new XQuery(query); System.out.println(cmd.execute(ctx));