Closed yrashk closed 8 months ago
The object json
is a shortcut to json(curly,dash,atom)
. The bug is more clear if we switch the object representation from curly
to list
:
?- json(list,dash,atom)::(parse(chars("\"{}\""), JSON), generate(chars(Chars), JSON)).
JSON = {},
Chars = ['{', '}'].
?- json(list,dash,atom)::(parse(chars("{}"), JSON), generate(chars(Chars), JSON)).
JSON = json([]),
Chars = ['{', '}'].
In the first query we get an atom representation of the string, {}
. In the second case, you get an empty object using list representation, json([])
. I.e. the binding of the JSON
variable is correct in both cases. But the binding for the variable Chars
is incorrect in the first query. Fixed in bb44467c002f609fdfe86cfbdfab080c0d71acb7.
Thank you! This was great 💯
It looks like generating JSON with a string that looks like an empty object (
"{}"
) generates unexpected JSON:Compare this:
to