Summary
RFC 0006 specifies string() on a list produces "the JSON string representation".
string(['a"b']) returns ["a"b"] — the embedded " is not escaped as \", so the output
is not valid JSON: the third " closes the string early.
Versions
openjd-model 0.11.1 and 0.11.2 from PyPI
openjd-rs main at 1a89f3a — still reproduces
Reproduction
import json
from openjd.expr import parse_expression
r = parse_expression("string(['a\"b'])").evaluate_with_metrics()
out = str(r.value)
print(out) # -> ["a"b"]
json.loads(out) # -> json.decoder.JSONDecodeError:
# Expecting ',' delimiter: line 1 column 5 (char 4)
Why this is a bug
The output is consumed as JSON by construction ("the JSON string representation"), and this
one is rejected by any JSON parser. Note repr_json handles the same input correctly — the
escaping gap is specific to string()'s list path.
Summary
RFC 0006 specifies
string()on a list produces "the JSON string representation".string(['a"b'])returns["a"b"]— the embedded"is not escaped as\", so the outputis not valid JSON: the third
"closes the string early.Versions
openjd-model0.11.1 and 0.11.2 from PyPIopenjd-rsmainat1a89f3a— still reproducesReproduction
Why this is a bug
The output is consumed as JSON by construction ("the JSON string representation"), and this
one is rejected by any JSON parser. Note
repr_jsonhandles the same input correctly — theescaping gap is specific to
string()'s list path.