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
2
votes
1 answer

To compare json values in c++ using rapidjson

I am javascript developer , new to c++ . I have written a code in js and want that to be implemented in c++ using rapidjson. The aim of the code is to compare two json with the 3rd json which is a reference. import React, { Component } from…
A.v
  • 31
  • 1
  • 8
2
votes
1 answer

Rapid json parser returns null when it tries to parse '\n' character

My Input string is like this: std::string temp = "{\"key\":\""+ message + "\"}"; For Eg: message can be like this: "Stack \n Overflow" message can be anything. It can contain escape sequence characters also. I expect this is a valid JSON and if I…
Akhilesh
  • 31
  • 6
2
votes
1 answer

The use of Move in Rapidjson

I wonder difference in rapidjson between the follow two ways, I have already tried to read rapidjson doc but still confused about it. 1. doc.AddMember("tag", tag_str, doc.GetAllocator()); 2. doc.AddMember("tag", rapidjson::Value(tag_str).Move(),…
2
votes
0 answers

Build project with Appveyor and two toolsets MSVS and MinGW

There is a nice project RapidJson. It uses Appveyor CI to test builds for Windows and MSVC 2015. I am going to add build config for MinGW. But I cannot find a way how to do that. Please consider appveyor.yml from official repository: os: Visual…
kyb
  • 7,233
  • 5
  • 52
  • 105
2
votes
2 answers

Convert rapidjson array iterator to rapidjson::value

How do I convert a rapidjson array iterator to a rapidjson::value? I do not want answers that focus on how to get the contents of a rapid json array, or how to iterate through it. I am also very aware that I can access members through the iterator…
Christopher Pisz
  • 3,757
  • 4
  • 29
  • 65
2
votes
1 answer

C++ RapidJSON Clear written string

I have the following C++ code to generate a JSON-string: StringBuffer JSONData; PrettyWriter
TVA van Hesteren
  • 1,031
  • 3
  • 20
  • 47
2
votes
1 answer

How do I pass protobuf's boost::shared_ptr pointer to function?

I have to pass a boost::shared_ptr: boost::shared_ptr pProfile = boost::make_shared(); which is protobuf's pointer, to a protobuf's function oPerson.set_allocated_profile(pProfile) but…
CMouse
  • 130
  • 3
  • 19
2
votes
0 answers

Get string for entire rapidjson::Document

How do I get the entire rapidjson::Document as a string? I've got the following code: rapidjson::Document jsonDoc; rapidjson::MemoryPoolAllocator<> & allocator = jsonDoc.GetAllocator(); jsonDoc.SetObject(); jsonDoc.AddMember("ACTION", "poop",…
Christopher Pisz
  • 3,757
  • 4
  • 29
  • 65
2
votes
1 answer

serialize long string with rapid json will be truncated

I use rapid json to serialize a dict, the key is uint32 and the value is a long string. The code is: rapidjson::StringBuffer buffer(); …
2
votes
1 answer

How set up rapidjson without git

I need to use rapidjson as a third party library to replace libjson. I'm trying to figure out how to build it so I can use it's build files in my project (dependency list). I downloaded rapidjson from github, and I'm trying to get a buildable…
Michele
  • 3,617
  • 12
  • 47
  • 81
2
votes
1 answer

C++ rapidjson "‘rapidjson::Document’ has no member named ‘GetParseErrorCode'"

I am trying to compile this program: ` #include "rapidjson/document.h" #include "rapidjson/error/en.h" #include #include int main() { const char* json = "{" "\"hello\": \"world\"," "\"t\": \"world\"" …
TheWatcher _
  • 55
  • 1
  • 7
2
votes
2 answers

RapidJson And Boost Json Parser

Is there any difference between Rapid JSON and Json parser in Boost Library(Boost\property_Tree\Json_parser.hpp) Thanks.
vishnubvrit
  • 317
  • 1
  • 3
  • 14
2
votes
2 answers

C++ context error

I have a C++ class Tester.cpp that uses the rapidjson JSON parser. Here is an abbreviated version of the code: using namespace std; using namespace rapidjson; int main(int argc, char** argv) { ... //Parse the JSON rapidjson::Document…
2
votes
1 answer

How to retrieve key-value data in JSON file using rapidjson C++?

I have received a JSON string as follow: { "ret":"xxx", "error": [ { "errors": {"0":"0.2", "1":"0.3" } }, { "errors": {"2":"0.2", "3":"0.4" } } ] } I have written code to get all…
einverne
  • 6,454
  • 6
  • 45
  • 91
2
votes
2 answers

How can I add members to a rapidjson document using integers as the key/name?

I'm using a for loop and want to use the iterator, i, as the key/name when I add a member to the document. For example I want the document to look like this: {"1":"123.321","2":"456.654"} Here is what I have tried so far. 1. Converting i to a const…
cemanuel
  • 61
  • 1
  • 1
  • 8