-
-
Save kaworu/9f143adb781af1dc2194 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
struct json_field { | |
const char* field; | |
int is_here; | |
}; | |
int main(void) | |
{ | |
/* Met 0 ou 1 pour simuler l'absence/présence du champ */ | |
struct json_field fields[] = { { "'fsname': 'dev'", 1 }, | |
{ "'percentage_used': '0.000000'", 1 }, | |
{ "'mount_point': 'dev/'", 1 } }; | |
size_t i; | |
printf("{"); | |
const char *comma = ""; | |
for (i = 0; i < (sizeof fields/sizeof fields[0]); ++i) { | |
if (fields[i].is_here) { | |
printf("%s\n\t%s", comma, fields[i].field); | |
comma = ","; | |
} | |
} | |
puts("\n}"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment