Im using cJSON by Dave Gamble and have the following problem. If I change the value within a cJSON struct and then use the cJSON_Print command I dont get the updated values, instead I still get the default ones.
#include <stdio.h>
#include <stdlib.h>
#include "cJSON.h"
void main(){
cJSON *test = cJSON_Parse("{\"type\": \"rect\", \n\"width\": 1920, \n\"height\": 1080, \n\"interlace\": false,\"frame rate\": 24\n}");
printf("cJSONPrint: %s\n cJSONvalueint: %d\n",cJSON_Print(test), cJSON_GetObjectItem(test,"frame rate")->valueint);
cJSON_GetObjectItem(test,"frame rate")->valueint=15;
printf("cJSONPrint: %s\n cJSONvalueint: %d\n",cJSON_Print(test), cJSON_GetObjectItem(test,"frame rate")->valueint);
}
this is the code I used for a small test and it gives me those results:
cJSONPrint: {
"type": "rect",
"width": 1920,
"height": 1080,
"interlace": false,
"frame rate": 24
}
cJSONvalueint: 24
cJSONPrint: {
"type": "rect",
"width": 1920,
"height": 1080,
"interlace": false,
"frame rate": 24
}
cJSONvalueint: 15
Does anybody know what I'm doing wrong, and how to get the correct values with the cJSON_Print command ?