标签:ret opera cal next style object cjson test hone
#include <stdio.h> #include "cJSON.h" /* { "semantic": { "slots": { "name": "张三" } }, "rc": 0, "operation": "CALL", "service": "telephone", "text": "打电话给张三" } */ int main() { cJSON * root = cJSON_CreateObject(); cJSON * item = cJSON_CreateObject(); cJSON * next = cJSON_CreateObject(); cJSON_AddItemToObject(root, "rc", cJSON_CreateNumber(0)); cJSON_AddItemToObject(root, "operation", cJSON_CreateString("CALL")); cJSON_AddItemToObject(root, "service", cJSON_CreateString("telephone")); cJSON_AddItemToObject(root, "text", cJSON_CreateString("打电话给张三")); cJSON_AddItemToObject(root, "semantic", item); cJSON_AddItemToObject(item, "slots", next); cJSON_AddItemToObject(next, "name", cJSON_CreateString("张三")); printf("%s\n", cJSON_Print(root)); return 0; }
标签:ret opera cal next style object cjson test hone
原文地址:https://www.cnblogs.com/liyubo/p/9091159.html