https://github.com/epfl-dlab/transformers-CFG/blob/main/examples/grammars/json.ebnf#L6
I just realise that the grammar here for json only allows json object at root level.
In fact, json grammar accepts array and other atomic values like string or number at root level.
So a string itself is a valid json.
Here is the spec of JSON standard: https://www.json.org/json-en.html
Probably we just need to replace the root grammar rule json::=object to json::= value and fix the potentially impacted tests.
https://github.com/epfl-dlab/transformers-CFG/blob/main/examples/grammars/json.ebnf#L6
I just realise that the grammar here for json only allows json object at root level.
In fact, json grammar accepts array and other atomic values like string or number at root level.
So a string itself is a valid json.
Here is the spec of JSON standard: https://www.json.org/json-en.html
Probably we just need to replace the root grammar rule
json::=objecttojson::= valueand fix the potentially impacted tests.