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
1
vote
1 answer

How to create json using rapidjson::Writer without creating document in C++?

I am trying to create json using rapidjson::Writer without creating document but it just give json text but don't create full json output like below, { "data": { "dataIn": { "hello":"world", "t":true, "f":false }, "dataOut": { "n":null, "i":123,…
1
vote
1 answer

Parsing path in JSON

I'm trying to pass a JSON object containing a path from my frontend (Node) to the backend (C++) using RapidJSON, like so: #include #include "rapidjson/document.h" int main() { const char* json1 = "{\"path\":\"C:\\test.file\"}"; …
Markstar
  • 639
  • 9
  • 24
1
vote
1 answer

Garbage value in rapid json AddMember

{ std::string result; RapidJSON::Value json; json.SetObject(); for(int i = 0; i < 5; ++i) { RapidJSON::Value data; data.SetObject(); for(auto it = HashMap.begin(); it != HashMap.end(); it++) { …
PrabanjanRaja
  • 55
  • 1
  • 7
1
vote
0 answers

Issue while reading information from file using RapidJson

I'm trying to read a JSON file using RapidJson in C++ and am running into a problem Here is the JSON file below. { "organizations":[ ], "uuid":"e68495a399ffde815e06101d8ff0c8b69f205b9d", "thread":{ "social":{ …
Skydaz
  • 41
  • 2
1
vote
0 answers

How to handle schema errors in rapidjson?

How can I detect the following error situation: A rapidjson::SchemaDocument is constructed from a rapidjson::Document, but the JSON contained in that Document is no proper schema; for example, { "type": "object", "properties": [1] }. Currently, all…
h.s.
  • 139
  • 9
1
vote
1 answer

arrays of arrays writing to a file using rapidjson

Using below function I am writing vector of vector into a file and getting this: [[[1, 2, 3],[1, 2, 3],[1, 2, 3],[1, 2, 3]]] However I want the output to look like this: [[1, 2, 3],[1, 2, 3],[1, 2, 3],[1, 2, 3]] Code: void…
noman pouigt
  • 906
  • 11
  • 25
1
vote
1 answer

Compile OCCT7.5 with rapidjson using FreeCad Libpack?

I'm looking to compile OCCT 7.5 in Windows 10 (x64 via VS2019) for use with FreeCAD, to enable exporting glTF files, which requires RapidJSON support (in OCCT). I've checked out OCCT 7.5.3 and RapidJSON 1.1.0 from their git repos, then grabbed the…
NickT
  • 116
  • 1
  • 8
1
vote
1 answer

RapidJson allocation mechanism fundamentally flawed

First, the code... #include #include #include #include int main(int argc, char* argv[]) { using namespace rapidjson; Value author; { …
1
vote
1 answer

How to extract number from json?

I want to extract a specific array from a json file: { "status": "OK", "type": "startVehicle", "info": { "idTransit": 36612, "timestampUTCTransit": { "epochUTCTransitMS": 1606935562810, …
cavero00
  • 11
  • 3
1
vote
0 answers

rapidjson erase array and deallocate memory

i try to erase all array elements within a json file and add some new elements cyclically. The problem is, that the memory of the allocator will never be deallocated after erasing so the memory usage increases by every cycle. Here is my actual…
joen
  • 634
  • 2
  • 5
  • 14
1
vote
1 answer

Where the error come while parsing RapidJSON

I'm trying to parse a JSON file using RapidJSON, I've created this code to get the integers (in this case), however, I get errors saying that some variables are not members of the structure when they are included. The declared struct is the original…
pepe pep
  • 27
  • 5
1
vote
1 answer

Find RapidJSON value's parent

Given a Value in a RapidJSON document, is it possible to easily find that Value's parent? Specifically, we're using Pointer to find a value, but we then want to move back up one level to find that value's parent. I was hoping there would be an…
Doug Porter
  • 198
  • 12
1
vote
2 answers

How to use rapidjson library in my c++ code?

Actually I am trying to parse a json file using rapidjson library . But when i am trying to add this header file in my code it shows me an error like this "[Error] rapidjson/document.h: No such file or directory" and "recipe for target 'main_1.o'…
Ramya T
  • 19
  • 1
  • 2
1
vote
1 answer

Add set(distinct elements) in rapidjson

I want to create following Json object { "name":"abc", "property1"=[2010, 2013, 2015], "property2"=["str1, "str2", str3"], "property3"=[true, false] } property1, property2, property3 is basically an array but with distinct…
Dodez
  • 19
  • 2
1
vote
1 answer

How to Skip Parsing of Token in Rapidjson

I have to Parse only certain Tokens in Data Structure using RapidJson.And skip other tokens to save time. For eg. How to parse only "t" token without parsing other tokens { "hello": "world", "t": true , "f": false, "n": null, …
aniket dhole
  • 91
  • 1
  • 7