Skip to content

Commit

Permalink
xjson: Missing commas between fields
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Sep 29, 2024
1 parent 7b94836 commit 5a7ae6c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/xjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ static XStructure *ParseObject(char **pos, int *lineNumber) {
f->value = ParsePrimitive(&next, &f->type, lineNumber);
}

if(*next == ',')
next++;

f = xSetField(s, f);
if(f) xDestroyField(f); // If duplicate field, destroy the prior one.
}
Expand Down Expand Up @@ -887,7 +890,7 @@ static int GetFieldStringSize(int prefixSize, const XField *f) {

prop_error(fn, m);

return m + strlen(f->name) + 4; // name + " = " + value + "\n"
return m + strlen(f->name) + 5; // name + " = " + value + ",\n"
}


Expand All @@ -908,6 +911,7 @@ static int PrintField(const char *prefix, const XField *f, char *str) {
prop_error(fn, m);

n += m;
if(f->next) n += sprintf(&str[n], ",");
n += sprintf(&str[n], "\n");
return n;
}
Expand Down

0 comments on commit 5a7ae6c

Please sign in to comment.