我正在做一个休息 api,我在 c++ 中使用 cJSON c 库。
这是我的身体请求示例
{
"userEmail": "email@email.com",
"userPassword": "12345678"
}
在我的 c++ 程序中,我收到这样的 json(它现在可以工作):
cJSON *root;
root = cJSON_CreateObject();
cJSON_AddStringToObject(root, "userEmail", userEmail.c_str());
cJSON_AddStringToObject(root, "userPassword", userPassword.c_str());
现在我需要将我的正文请求更改为类似的内容:
{
"userInfo":{
"userEmail": "email@email.com",
"userPassword": "12345678"
}
}
注意:它不是一个数组,它就像一个 json 'section'。我没有找到任何解决方案来使用 cJSON 库获取“userInfo”(邮件和密码)中的内容。你能帮助我吗?
非常感谢