Questions tagged [rapidjson]

A fast JSON parser/generator for C++ with both SAX/DOM style API

Rapidjson is an attempt to create the fastest JSON parser and generator.

  • Small but complete. Supports both SAX and DOM style API. SAX parser only a few hundred lines of code.
  • Fast. In the order of magnitude of strlen(). Optionally supports SSE2/SSE4.2 for acceleration.
  • Self-contained. Minimal dependency on standard libraries. No BOOST, not even STL.
  • 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.
  • Full RFC4627 compliance. Supports UTF-8, UTF-16 and 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
  • Support custom memory allocation. 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.

As the name implies, rapidjson is inspired by rapidxml.

383 questions
0
votes
1 answer

C++ RapidJSON Writer and String Buffer outputting unknown characters

I have a class representing an object in 3-space, and a to_json method which outputs a const char* to convert the object into a JSON for writing back to a document based database. However, the to_json method is outputting unknown characters rather…
Alex Barry
  • 415
  • 1
  • 9
  • 21
0
votes
1 answer

Skip certain fields while parsing a document with RapidJSON

I'm using RapidJSON to parse large GeoJSON files. Most of the content in these files (and hence memory after parsing) is giant coordinate arrays. For my application, I'm not interested in these. I'd prefer to skip them (not allocate memory for them)…
danvk
  • 15,863
  • 5
  • 72
  • 116
0
votes
0 answers

RapidJSON cross compling fails on parsing JSON

I'm facing problems with RapidJSON using on my embedded target. Under Windows everything works like a charm. The following simple test does not work on my target: #include "rapidjson/document.h" #include "rapidjson/prettywriter.h" #include…
TR GT
  • 1
  • 1
0
votes
1 answer

How to get a "node" parsing a file with Rapidjson?

I'm using Rapidjson to retrieve data from a file, and I want to use that file data to create entities in my game. So, my file has the definition of what a certain entity is (in this case, each ship parameters and components to be created). File…
jjimenezg93
  • 162
  • 4
  • 16
0
votes
1 answer

Corrupt output, possibly due to lost ownership of rapidjson::Document::Allocator

I have some trouble with, what I think is, object ownership. My goal is to create a JSON-RPC message. What I want to achieve on a lower level is an array of objects, each of which has 1 object error. Everything goes fine, except for that inner error…
user6124606
0
votes
1 answer

Rapidjson not reading file

I've searched for this specific error but I didn't find any related question. I'm trying to use Rapidjson to parse .json files in my C++ project, and this is how I'm doing it (following what RapidJSON tutorial states): main.cpp #include…
jjimenezg93
  • 162
  • 4
  • 16
0
votes
1 answer

xml to json conversion c++

I'm developing a C++ (visual studio 2005) app which converts xml to json I'm using rapidxml and rapidjson libraries. XML Gambardella, Matthew XML Developer's…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c++" class="post-tag grid--cell" title="show questions tagged 'c++'" rel="tag">c++</a> <a href="../../questions/tagged/json" class="post-tag grid--cell" title="show questions tagged 'json'" rel="tag">json</a> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/rapidxml" class="post-tag grid--cell" title="show questions tagged 'rapidxml'" rel="tag">rapidxml</a> <a href="../../questions/tagged/rapidjson" class="post-tag grid--cell" title="show questions tagged 'rapidjson'" rel="tag">rapidjson</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Mar 17 '16 at 13:25">asked Mar 17 '16 at 13:25</time> <a href="../../users/2551701/boukeri-besmen" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2551701.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="BOUKERI Besmen" /> </a> <div class="s-user-card--info"> <a href="../../users/2551701/boukeri-besmen" class="s-user-card--link">BOUKERI Besmen</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">13</li> <li class="s-award-bling s-award-bling__bronze" title="8 bronze badges">8</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-35222230"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/35222230/cpp-rapidjson-resolve-key-conflicts-without-information-loss" class="question-hyperlink">cpp RapidJSON - Resolve key conflicts without information loss</a></h3> <div class="excerpt">I want to parse a text file which is similar to JSON. After some character conversions, it still has some objects, which have key conflicts. So my JSON looked like this: { "key1": { "a": "asdf", "a": "foo", "a": "bar", …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c++" class="post-tag grid--cell" title="show questions tagged 'c++'" rel="tag">c++</a> <a href="../../questions/tagged/json" class="post-tag grid--cell" title="show questions tagged 'json'" rel="tag">json</a> <a href="../../questions/tagged/rapidjson" class="post-tag grid--cell" title="show questions tagged 'rapidjson'" rel="tag">rapidjson</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Feb 05 '16 at 10:49">asked Feb 05 '16 at 10:49</time> <a href="../../users/5406906/nils-ballmann" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/5406906.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Nils Ballmann" /> </a> <div class="s-user-card--info"> <a href="../../users/5406906/nils-ballmann" class="s-user-card--link">Nils Ballmann</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">645</li> <li class="s-award-bling s-award-bling__silver" title="10 silver badges">10</li> <li class="s-award-bling s-award-bling__bronze" title="11 bronze badges">11</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-34748465"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/34748465/how-to-update-an-array-using-rapidjson" class="question-hyperlink">how to update an array using rapidjson?</a></h3> <div class="excerpt">i doing some stuff with rapidjson and i want to add values to an array i just created like that #include <iostream> #include "rapidjson/document.h" using namespace std ; int main() { char json[1024]; rapidjson::Document document ; …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c++" class="post-tag grid--cell" title="show questions tagged 'c++'" rel="tag">c++</a> <a href="../../questions/tagged/rapidjson" class="post-tag grid--cell" title="show questions tagged 'rapidjson'" rel="tag">rapidjson</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jan 12 '16 at 16:09">asked Jan 12 '16 at 16:09</time> <a href="../../users/5382698/mohammed-talat" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/5382698.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Mohammed Talat" /> </a> <div class="s-user-card--info"> <a href="../../users/5382698/mohammed-talat" class="s-user-card--link">Mohammed Talat</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">77</li> <li class="s-award-bling s-award-bling__silver" title="2 silver badges">2</li> <li class="s-award-bling s-award-bling__bronze" title="12 bronze badges">12</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-34583903"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/34583903/use-rapidjson-in-cocos2dx-it-crash-in-accept-writer-in-ios" class="question-hyperlink">Use RapidJson in Cocos2dx, it crash in Accept(writer) in IOS</a></h3> <div class="excerpt">I use Cocos2dx 3.9; and use rapidjson to convert CCDictionary to string; I find it will crash in value->Accept(wirter) in Real machine; but work will in Simulator. rapidjson::StringBuffer buffer; rapidjson::Writer<rapidjson::StringBuffer>…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/ios" class="post-tag grid--cell" title="show questions tagged 'ios'" rel="tag">ios</a> <a href="../../questions/tagged/cocos2d-x" class="post-tag grid--cell" title="show questions tagged 'cocos2d-x'" rel="tag">cocos2d-x</a> <a href="../../questions/tagged/rapidjson" class="post-tag grid--cell" title="show questions tagged 'rapidjson'" rel="tag">rapidjson</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jan 04 '16 at 02:24">asked Jan 04 '16 at 02:24</time> <a href="../../users/5741918/long-j" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/5741918.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Long J" /> </a> <div class="s-user-card--info"> <a href="../../users/5741918/long-j" class="s-user-card--link">Long J</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">13</li> <li class="s-award-bling s-award-bling__bronze" title="4 bronze badges">4</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-34278118"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/34278118/rapidjson-cocos2d-x-parsing" class="question-hyperlink">rapidjson cocos2d-x parsing</a></h3> <div class="excerpt">rapidjson::Document d; d.Parse<0>(chatevent.chat.c_str()); if(d.HasMember("kelimeler")) { rapidjson::Value::MemberIterator M; const char *key,*value; for (M=d.MemberBegin(); M!=d.MemberEnd(); M++) { …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c++" class="post-tag grid--cell" title="show questions tagged 'c++'" rel="tag">c++</a> <a href="../../questions/tagged/json" class="post-tag grid--cell" title="show questions tagged 'json'" rel="tag">json</a> <a href="../../questions/tagged/cocos2d-x" class="post-tag grid--cell" title="show questions tagged 'cocos2d-x'" rel="tag">cocos2d-x</a> <a href="../../questions/tagged/rapidjson" class="post-tag grid--cell" title="show questions tagged 'rapidjson'" rel="tag">rapidjson</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 14 '15 at 22:54">asked Dec 14 '15 at 22:54</time> <a href="../../users/1240167/gokturk" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1240167.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="gokturk" /> </a> <div class="s-user-card--info"> <a href="../../users/1240167/gokturk" class="s-user-card--link">gokturk</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">116</li> <li class="s-award-bling s-award-bling__silver" title="2 silver badges">2</li> <li class="s-award-bling s-award-bling__bronze" title="13 bronze badges">13</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-34122862"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/34122862/i-want-to-edit-a-file-with-rapidjson-but-when-i-do-the-file-is-not-saved" class="question-hyperlink">I want to edit a file with RapidJSON but when I do, the file is not saved</a></h3> <div class="excerpt">This is my code std::ifstream infile("/home/alexander/MyCompany/MyGame/Resources/res/puzzles(copia).json"); std::string line; std::ofstream ofs("/home/alexander/MyCompany/MyGame/Resources/res/temporal.json", std::ofstream::out); Document…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c++" class="post-tag grid--cell" title="show questions tagged 'c++'" rel="tag">c++</a> <a href="../../questions/tagged/cocos2d-x" class="post-tag grid--cell" title="show questions tagged 'cocos2d-x'" rel="tag">cocos2d-x</a> <a href="../../questions/tagged/rapidjson" class="post-tag grid--cell" title="show questions tagged 'rapidjson'" rel="tag">rapidjson</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 06 '15 at 21:15">asked Dec 06 '15 at 21:15</time> <a href="../../users/3353152/d4ivt3" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/3353152.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="D4IVT3" /> </a> <div class="s-user-card--info"> <a href="../../users/3353152/d4ivt3" class="s-user-card--link">D4IVT3</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">101</li> <li class="s-award-bling s-award-bling__silver" title="1 silver badges">1</li> <li class="s-award-bling s-award-bling__bronze" title="17 bronze badges">17</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-34033425"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/34033425/c-rapidjson-removing-unicode-python-prefix-from-json-string-for-parsing" class="question-hyperlink">C++/RapidJSON: Removing unicode Python prefix from JSON string for parsing</a></h3> <div class="excerpt">I have a Python web API that returns a JSON with the "u" prefix instead of the standard double quotes. I want to be able to parse this in C++ using the RapidJSON document.Parse(string) function, however the Python formatting prevents RapidJSON from…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/c++" class="post-tag grid--cell" title="show questions tagged 'c++'" rel="tag">c++</a> <a href="../../questions/tagged/json" class="post-tag grid--cell" title="show questions tagged 'json'" rel="tag">json</a> <a href="../../questions/tagged/unicode" class="post-tag grid--cell" title="show questions tagged 'unicode'" rel="tag">unicode</a> <a href="../../questions/tagged/rapidjson" class="post-tag grid--cell" title="show questions tagged 'rapidjson'" rel="tag">rapidjson</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 02 '15 at 01:32">asked Dec 02 '15 at 01:32</time> <a href="../../users/4247145/kevin" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/4247145.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Kevin" /> </a> <div class="s-user-card--info"> <a href="../../users/4247145/kevin" class="s-user-card--link">Kevin</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">13</li> <li class="s-award-bling s-award-bling__bronze" title="4 bronze badges">4</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-33881030"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>0</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/33881030/function-with-rapidjson-value-parameter-wants-an-allocator-when-called" class="question-hyperlink">Function with rapidjson::Value& parameter wants an allocator when called</a></h3> <div class="excerpt">I have a similar issue as an earlier question (see Parsing object inside array in rapidjson ) where I am writing a recursive function to walk an arbitrary JSON tree, and I tried the suggested answer, but my C++ compiler does not like it. I have…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c++" class="post-tag grid--cell" title="show questions tagged 'c++'" rel="tag">c++</a> <a href="../../questions/tagged/rapidjson" class="post-tag grid--cell" title="show questions tagged 'rapidjson'" rel="tag">rapidjson</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Nov 23 '15 at 21:27">asked Nov 23 '15 at 21:27</time> <a href="../../users/5596898/eric-j" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/5596898.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Eric J" /> </a> <div class="s-user-card--info"> <a href="../../users/5596898/eric-j" class="s-user-card--link">Eric J</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-33292836"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/33292836/how-to-access-rapidjson-objects-in-order" class="question-hyperlink">How to access rapidJSON objects in order</a></h3> <div class="excerpt">Let's say I have a JSON object { "Obj1":{ "Obj2":{ "Obj3":{ } } } } Is there a way to access each member without querying it's name or using an iterator. If I have the reference to…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c++" class="post-tag grid--cell" title="show questions tagged 'c++'" rel="tag">c++</a> <a href="../../questions/tagged/json" class="post-tag grid--cell" title="show questions tagged 'json'" rel="tag">json</a> <a href="../../questions/tagged/rapidjson" class="post-tag grid--cell" title="show questions tagged 'rapidjson'" rel="tag">rapidjson</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card__deleted"> <time class="s-user-card--time" datetime="asked Oct 23 '15 at 00:08">asked Oct 23 '15 at 00:08</time> <div class="s-avatar s-avatar__32 s-user-card--avatar"> </div> <div class="s-user-card--info">user3267587</div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <a class="s-pagination--item" href="../../questions/tagged/rapidjson_page=22" rel="prev" title="Go to page 22">Prev </a> <a class="s-pagination--item" href="../../questions/tagged/rapidjson_page=1" rel="" title="Go to page 1">1</a> <a class="s-pagination--item" href="../../questions/tagged/rapidjson_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/rapidjson_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/rapidjson_page=25" rel="" title="Go to page 25">25</a> <a class="s-pagination--item" href="../../questions/tagged/rapidjson_page=26" rel="" title="Go to page 26">26</a> <a class="s-pagination--item" href="../../questions/tagged/rapidjson_page=24" rel="next" title="Go to page 24"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>