【发布时间】:2013-02-14 16:48:13
【问题描述】:
我有以下代码
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <json/json.h>
int main(int argc, char **argv)
{
json_object *new_obj;
char buf[] = "{ \"foo\": \"bar\", \"foo2\": \"bar2\", \"foo3\": \"bar3\" }"
new_obj = json_tokener_parse(buf);
printf("The value of foo is %s" /*What I have to put here?*/);
printf("The value of foo2 is %s" /*What I have to put here?*/);
printf("The value of foo3 is %s" /*What I have to put here?*/);
json_object_put(new_obj);
}
我知道我们必须使用 json_tokener_parse() 来解析 json 字符串,但是我不知道如何从 json_object new_obj 中提取值,如上面代码中的 cmets 所示
json_tokener_parse() 之后如何获取 json 值?
【问题讨论】: