diff --git a/src/object.c b/src/object.c index ba2b95f..3c4034a 100644 --- a/src/object.c +++ b/src/object.c @@ -191,7 +191,12 @@ void stringStruct(struct string* s, const Object* obj) struct StructDef* def = getStructAt(so->definition); for (int i = 0; i < def->fieldCount; i++) { - appendf(s, " %s: ", def->names[i]); + appendf(s, " \"%s\": ", def->names[i]); + if (so->fields[i].type == TYPE_SYMBOL && so->fields[i].string == NULL) { + appendf(s, "null,"); + continue; + } + int isString = so->fields[i].type == TYPE_STRING; if (isString) { appendf(s, "\""); diff --git a/src/tests.sh b/src/tests.sh index dc569e3..ff954ec 100755 --- a/src/tests.sh +++ b/src/tests.sh @@ -206,7 +206,7 @@ title "Structs" check "Struct Definition" "(struct Post (title body))" "T" check "Building a struct"\ '(struct Post (title body)) (Post "A title" "The Body")'\ - '{ title: "A title", body: "The Body" }' + '{ "title": "A title", "body": "The Body" }' check "Accessing struct fields"\ "(struct Post (title body)) (def p (Post \"TITLE\" \"BODY\")) (p.title p.body)"\ "( TITLE BODY )"