아래 예제를 참고한다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <json-c/json.h>
json_object *myobj = json_object_new_object();
json_object_object_add(myobj,"name", json_object_new_string("KIM"));
json_object_object_add(myobj,"phone", json_object_new_string("01000000000"));
const char *result_json = json_object_to_json_string_next(myobj, JSON_C_TO_STRING_PLAIN);
printf("json:L %s \n", result_json);
json_object *root, *name, *phone;
root = json_tokener_parse(result_json);
json_object_object_get_ex(root, "name", &name);
json_object_object_get_ex(root, "phone", &phone);
printf("name : %s, phone : %s \n", json_object_get_string(name), json_object_get_string(phone));
|
cs |
'프로그래밍 > C언어' 카테고리의 다른 글
curl 을 이용한 클라이언트 get , post 요청 (0) | 2022.07.11 |
---|---|
연결리스트로 스택 만들기 (0) | 2022.07.10 |
연결 리스트로 큐 생성 (0) | 2022.07.10 |
Msg Queue (0) | 2022.06.14 |
파일입출력, 라인단위 읽고쓰기 (0) | 2019.07.23 |