cJSON#u Print dosen';不显示更新的值

cJSON#u Print dosen';不显示更新的值,c,json,cjson,C,Json,Cjson,我使用的是Dave Gamble的cJSON,有以下问题。 如果我在cJSON结构中更改了值,然后使用cJSON_Print命令,我不会得到更新后的值,而是会得到默认值 #include <stdio.h> #include <stdlib.h> #include "cJSON.h" void main(){ cJSON *test = cJSON_Parse("{\"type\": \"rect\", \n\"width\": 1920,

我使用的是Dave Gamble的cJSON,有以下问题。 如果我在cJSON结构中更改了值,然后使用cJSON_Print命令,我不会得到更新后的值,而是会得到默认值

#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);
}

有人知道我做错了什么,以及如何使用cJSON_Print命令获得正确的值吗?

我认为正确的调用需要使用cJSON_SetIntValue

它在对象上设置valueint和valuedouble,而不仅仅是valueint

#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_SetIntValue(cJSON_GetObjectItem(test, "frame rate"), 15);

    printf("cJSONPrint: %s\n  cJSONvalueint: %d\n",cJSON_Print(test), cJSON_GetObjectItem(test,"frame rate")->valueint);
}

对不起,我是Stackoverflow的新手,首先我不明白你的意思。希望一切都好,再次感谢。
#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_SetIntValue(cJSON_GetObjectItem(test, "frame rate"), 15);

    printf("cJSONPrint: %s\n  cJSONvalueint: %d\n",cJSON_Print(test), cJSON_GetObjectItem(test,"frame rate")->valueint);
}
$ ./test
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":   15
}
  cJSONvalueint: 15