[译]JSON的C语言实现: JSON-C - A JSON implementation in C
Posted by bianbian on 2006-12-17 15:44
本文Tags: JSON
[翻译] JSON-C能让你在C语言里轻松创建JSON对象,输出JSON字符串,解析JSON字符串成JSON对象。
test1.c的部分实例代码:
- struct json_object *my_array;
- my_array = json_object_new_array();
- json_object_array_add(my_array, json_object_new_int(1));
- json_object_array_add(my_array, json_object_new_int(2));
- json_object_array_add(my_array, json_object_new_int(3));
- json_object_array_put_idx(my_array, 4, json_object_new_int(5));
- printf("my_array=\n");
- for(i=0; i < json_object_array_length(my_array); i++) {
- struct json_object *obj = json_object_array_get_idx(my_array, i);
- printf("\t[%d]=%s\n", i, json_object_to_json_string(obj));
- }
- printf("my_array.to_string()=%s\n", json_object_to_json_string(my_array));
地址: http://oss.metaparadigm.com/json-c/
[Original] JSON-C implements a reference counting object model that allows you to easily construct JSON objects in C, output them as JSON formatted strings and parse JSON formatted strings back into the C representation of JSON objects.
Copyright Metaparadigm Pte. Ltd. 2004, 2005. Michael Clark
如果不清楚JSON,请参考:http://www.json.org
标签: JSON遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道
December 17th, 2006 at 10:16:03
试了一下,也支持中文。呵呵。倒是可以考虑用一下。
December 20th, 2006 at 02:01:30
有的时候感觉JSON比XML好用得多~~一个eval就OK了