Using google’s json parser, i test file’s content to see if it can be parsed:
...
FileReader fullPathToAndNameOfFile = new FileReader(file);
isJson(fullPathToAndNameOfFile);
...
private static boolean isJson(FileReader f) {
try {
parser.parse(f);
} catch (Exception e) {
return false;
}
return true;
}
The problem is .. the following format validates without errors:
a:12
b:27
c:Mike
Which, of course is not a valid JSON format.
Why is this?
I am not able to reproduce the poblem with below code.
Inside mainOutput for your given file contents =
invalid.If I change the file content to valid json. For eg:
Output =
valid