Cjson example
This commit is contained in:
parent
538a9987e0
commit
12b2d399d6
1 changed files with 17 additions and 0 deletions
17
cjson/cjson.c
Normal file
17
cjson/cjson.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
#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);
|
||||
cJSON_Delete(root);
|
||||
return message; // Remember to free this when done!
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
printf("%s\n", build_set_level_command(10));
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue