這個東西,寫C++外掛程式的可以用到。 RapidJSON —— C++ 快速 JSON 解析器和產生器

來源:互聯網
上載者:User

標籤:

原文:

RapidJSON —— C++ 快速 JSON 解析器和產生器時間 2015-04-05 07:33:33  開源中國新聞原文  http://www.oschina.net/p/rapidjson

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.

這個東西,寫C++外掛程式的可以用到。 RapidJSON —— C++ 快速 JSON 解析器和產生器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.