Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ void JsonObjectAppendString(JsonElement *object, const char *key, const char *va
assert(object->type == JSON_ELEMENT_TYPE_CONTAINER);
assert(object->container.type == JSON_CONTAINER_TYPE_OBJECT);
assert(key);

if(!value)
{
value = "";
}
assert(value);

JsonElement *child = JsonElementCreatePrimitive(JSON_PRIMITIVE_TYPE_STRING, key, EscapeJsonString(value));

Expand Down
12 changes: 12 additions & 0 deletions src/string_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,15 @@ long StringToLong(const char *str)

return result;
}

/*********************************************************************/

char *NULLStringToEmpty(char *str)
{
if(!str)
{
return "";
}

return str;
}
1 change: 1 addition & 0 deletions src/string_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ char *ToLowerStr(const char *str);
void ToLowerStrInplace(char *str);

long StringToLong(const char *str);
char *NULLStringToEmpty(char *str);

bool IsNumber(const char *name);

Expand Down