Talkson C++的JSON操作库

程序名称:Talkson

授权协议: Apache

操作系统: Windows

开发语言: C/C++

Talkson 介绍

Talkson 是一个 C++ 库,包含 JSON 消息的编码和解码模块。是一个简单、轻量级的 JSON 解析器,无需依赖外部库,支持流数据解析。

将对象转成 JSON 字符串的示例代码:

// create a JSON value. This example uses the root object of the above example.
....

// serialize
JSONObjectSerializer encoder;

if( root->type == JSONValue::Object )
{
        pos = 0;
        encoder.open( root );
        while( (pos = encoder.encode( buf, BUF_SIZE )) > 0 )
                printf( "%.*s", pos, buf );
}
else if( root->type == JSONValue::Array )
{
        pos = 0;
        JSONArraySerializer encoder;
        encoder.open( root );
        while( (pos = encoder.encode( buf, BUF_SIZE )) > 0 )
                printf( "%.*s", pos, buf );
}

delete root;

Talkson 官网

http://code.google.com/p/talkson/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐