c/c++使用json

9 篇文章 0 订阅

1. JSON_parser 只是对json语法的解析, 是基于sax的. 用于学习挺好的.
2. mjson 同时有dom和sax的完整解析方案, 很不错.
3. tinyjson是基于boost库的解析器, 用于学习挺好的.
4. json-c使用autoconfig兼容性最好,移植是个问题.

 

最后选择mjson.

修改json.h

//#include <stdint.h>

 

 

typedef __int64 int64_t;

typedef unsigned __int64 uint64_t;

 

 

例子(好像部分有问题):

http://mjson.sourceforge.net/examples.html

 

 

#include <stdio.h>

#include <stdlib.h>

#include <locale.h>

#include "json.h"

 

int _tmain(int argc, _TCHAR* argv[])

{

setlocale (LC_ALL, "");

char *document = "{/"entry/":{/"name/":/"Andew/",/"phone/":/"555 123 456/"}}";

 

json_t *root = NULL;

printf("Parsing the document.../n");

 

json_parse_document(&root, document);

 

printf("Printing the document tree.../n");

json_tree_to_string(root, &document);

 

printf("%s/n", document);    

json_free_value(&root);

 

free(document);

 

return EXIT_SUCCESS;

}

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值