Stepped over some test cases where JSON.parse() differs
from atom_json_term/3. Is there any option to get the same
behaviour? These are the JSON.parse() test cases:
/* Test Case 1 */
console.log(JSON.parse('{"result":true, "count":42}'));
> Object { result: true, count: 42 }
/* Test Case 2 */
console.log(JSON.parse(' '));
Error: Unexpected end of JSON input
/* Test Case 3 */
console.log(JSON.parse('{"result":true, "count":42} "foo"'));
Error: Unexpected non-whitespace character after JSON ...
And this is what SWI-Prolog does:
/* Test Case 1 */
?- atom_json_term('{"result":true, "count":42}', X, []).
X = json([result= @(true), count=42]).
/* Test Case 2 */
?- atom_json_term(' ', X, []).
ERROR: Stream <stream>(0000011ce68c7ea0):1:1
Syntax error: json(unexpected_end_of_file)
/* Test Case 3 */
?- atom_json_term('{"result":true, "count":42} "foo"', X, []).
X = json([result= @(true), count=42]).
So test case 1 and test case 2 are fine. But it seems that
superflous input content is not detected, so test case 3 differs.