zoukankan      html  css  js  c++  java
  • 这个东西,写C++插件的可以用到。 RapidJSON —— C++ 快速 JSON 解析器和生成器

    点这里

    原文:

    RapidJSON —— C++ 快速 JSON 解析器和生成器

    4月18日 武汉 源创会开始报名,送华为开发板

    Rapidjson 是一个 C++ 的快速 JSON 解析器和生成器,使用 SAX/DOM 风格的 API 设计。

    示例代码:

    // rapidjson/example/simpledom/simpledom.cpp`
    #include "rapidjson/document.h"
    #include "rapidjson/writer.h"
    #include "rapidjson/stringbuffer.h"
    #include <iostream>
    using namespace rapidjson;
    int main() {
      // 1. Parse a JSON string into DOM.
      const char* json = "{"project":"rapidjson","stars":10}";
      Document d;
      d.Parse(json);
      // 2. Modify it by DOM.
      Value& s = d["stars"];
      s.SetInt(s.GetInt() + 1);
      // 3. Stringify the DOM
      StringBuffer buffer;
      Writer<StringBuffer> writer(buffer);
      d.Accept(writer);
      // Output {"project":"rapidjson","stars":11}
      std::cout << buffer.GetString() << std::endl;
      return 0;
    }
    

    介绍 PPT 下载: http://www.oschina.net/doc/5711

    主要特点:

    • 体积小,功能全,提供 SAX 和 DOM 风格的 API,仅是 SAX 解析器只有百行代码

    • 快速

    • 无需依赖其他第三方库

    • Compact. Each JSON value is 16 or 20 bytes for 32 or 64-bit machines respectively (excluding text string storage). With the custom memory allocator, parser allocates memory compactly during parsing.

    • 完全兼容 RFC4627 ,支持 UTF-8, UTF-16 和 UTF-32.

    • Support both in-situ parsing (directly decode strings into the source JSON text) and non-destructive parsing (decode strings into new buffers).

    • Parse number to int/unsigned/int64_t/uint64_t/double depending on input

    • 支持自定义内存分配。Also, the default memory pool allocator can also be supplied with a user buffer (such as a buffer allocated on user's heap or programme stack) to minimize allocation.

  • 相关阅读:
    观光公交
    审查(银)
    小木棍 && 愤怒的小鸟
    SDOI2008 仪仗队 && SDOI2012 Longge的问题 && q
    斗地主 && Mayan游戏 && 作业调度方案
    过河
    跳跳棋
    count
    Cow Tennis Tournament
    luogu P1534不高兴的津津(升级版)
  • 原文地址:https://www.cnblogs.com/RTdo/p/4395798.html
Copyright © 2011-2022 走看看