The following code produces an error
def c = '{"codeWithScope": { "$code": "int x = y", "$scope": { "y": 1 } } }' new DocumentCodec().decode(new JsonReader(c), DecoderContext.builder().build())
Error: org.bson.json.JsonParseException: JSON reader was expecting a name but found '{'.