Cjson update
This commit is contained in:
parent
88146af0ad
commit
4056473705
2 changed files with 15 additions and 2 deletions
18
cjson/main.c
Normal file
18
cjson/main.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include <cjson/cJSON.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char *build_set_level_command(int level) {
|
||||
cJSON *root = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(root, "cmd", "set_level");
|
||||
cJSON_AddNumberToObject(root, "level", level);
|
||||
|
||||
// char *message = cJSON_PrintUnformatted(root);
|
||||
char *msg2 = cJSON_Print(root);
|
||||
cJSON_Delete(root);
|
||||
return msg2; // Remember to free this when done!
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
printf("%s\n", build_set_level_command(10));
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue