728x90
/* setting */
json_object *subobj, *taglist_obj, *tag_obj;
subobj = json_object_new_object();
taglist_obj = json_object_new_array();
tag_obj = json_object_new_string("test1");
json_object_array_add(taglist_obj, tag_obj);
tag_obj = json_object_new_string("test2");
json_object_array_add(taglist_obj, tag_obj);
/* merge */
json_object_object_add(subobj, "tag_list", taglist_obj);
/* free */
json_object_put(taglist_obj);
json_object_put(tag_obj);
json_object_put(subobj);
---------------------------------------------------------------
/* output */
"asdfsf" : {
"tag_list":[ "test1", "test2"]
}
tag_list만 볼 것 나머진 다 약식으로 가라다..
저런식으로 array를 만들어 줄 수 있다.
사실 array로 제목을 정했지만 중요한건
tag_obj = json_object_new_string("test1"); 이고
tag_obj = json_object_new_int(1234); 이런식도 가능하다.
728x90
'개발 업무(코딩)-개발자였을때 썼던..' 카테고리의 다른 글
swagger 함수들 예시 (0) | 2023.01.09 |
---|---|
was 시작 (0) | 2023.01.09 |
mysql(mariadb)에서 .sql 파일 실행시키기 (0) | 2023.01.09 |
tcp recv에 대한 고찰 (0) | 2023.01.09 |
리눅스 서버 설치(대략적인 순서) (0) | 2023.01.09 |