null or empty strings should be omitted
This commit is contained in:
parent
7324ae890c
commit
ee11358d7f
1 changed files with 10 additions and 5 deletions
|
@ -41,7 +41,7 @@ struct WriteArray {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void WriteOptionalString(JsonWriter& w, T& k, const char* value)
|
void WriteOptionalString(JsonWriter& w, T& k, const char* value)
|
||||||
{
|
{
|
||||||
if (value) {
|
if (value && value[0]) {
|
||||||
w.Key(k, sizeof(T) - 1);
|
w.Key(k, sizeof(T) - 1);
|
||||||
w.String(value);
|
w.String(value);
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,10 @@ size_t JsonWriteRichPresenceObj(char* dest,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (presence->largeImageKey || presence->largeImageText ||
|
if ((presence->largeImageKey && presence->largeImageKey[0]) ||
|
||||||
presence->smallImageKey || presence->smallImageText) {
|
(presence->largeImageText && presence->largeImageText[0]) ||
|
||||||
|
(presence->smallImageKey && presence->smallImageKey[0]) ||
|
||||||
|
(presence->smallImageText && presence->smallImageText[0])) {
|
||||||
WriteObject assets(writer, "assets");
|
WriteObject assets(writer, "assets");
|
||||||
WriteOptionalString(writer, "large_image", presence->largeImageKey);
|
WriteOptionalString(writer, "large_image", presence->largeImageKey);
|
||||||
WriteOptionalString(writer, "large_text", presence->largeImageText);
|
WriteOptionalString(writer, "large_text", presence->largeImageText);
|
||||||
|
@ -106,7 +108,8 @@ size_t JsonWriteRichPresenceObj(char* dest,
|
||||||
WriteOptionalString(writer, "small_text", presence->smallImageText);
|
WriteOptionalString(writer, "small_text", presence->smallImageText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (presence->partyId || presence->partySize || presence->partyMax) {
|
if ((presence->partyId && presence->partyId[0]) || presence->partySize ||
|
||||||
|
presence->partyMax) {
|
||||||
WriteObject party(writer, "party");
|
WriteObject party(writer, "party");
|
||||||
WriteOptionalString(writer, "id", presence->partyId);
|
WriteOptionalString(writer, "id", presence->partyId);
|
||||||
if (presence->partySize) {
|
if (presence->partySize) {
|
||||||
|
@ -118,7 +121,9 @@ size_t JsonWriteRichPresenceObj(char* dest,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (presence->matchSecret || presence->joinSecret || presence->spectateSecret) {
|
if ((presence->matchSecret && presence->matchSecret[0]) ||
|
||||||
|
(presence->joinSecret && presence->joinSecret[0]) ||
|
||||||
|
(presence->spectateSecret && presence->joinSecret[0])) {
|
||||||
WriteObject secrets(writer, "secrets");
|
WriteObject secrets(writer, "secrets");
|
||||||
WriteOptionalString(writer, "match", presence->matchSecret);
|
WriteOptionalString(writer, "match", presence->matchSecret);
|
||||||
WriteOptionalString(writer, "join", presence->joinSecret);
|
WriteOptionalString(writer, "join", presence->joinSecret);
|
||||||
|
|
Loading…
Reference in a new issue