JSON is based on clear text, so itβs not at all surprising that Tika reported this as such when it was given only bytes with which to work.
Your problem is that you also did not specify a file name, so Tiki did not have something to work with. If you had, Tika could say bytes=plain text + filename=json => json and gave you the answer you expected
Invalid line:
metadata.set(Metadata.RESOURCE_NAME_KEY, filename);
Thus, a fixed piece of code will look like this:
tikaIS = TikaInputStream.get(file); final Metadata metadata = new Metadata(); metadata.set(Metadata.RESOURCE_NAME_KEY, file.getName()); return DETECTOR.detect(tikaIS, metadata).toString();
In doing so, you will receive a response from JSON, as you expected
source share