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

Remove nested object in JSON with rapidjson

I'm trying to remove object nested in object in JSON file. However, I can not find any examples on the internet or on the official rapidjson page. My code is written on C++. I have tried with the following code: const Value& rootObject=…
Mario
  • 87
  • 2
  • 10
0
votes
1 answer

Add a definition in project properties (eclipse) with cmake

I'm using rapidjson and I want to use std::string's with it. Then I have to define this -DRAPIDJSON_HAS_STDSTRING. My CMakeLists.txt have now: add_definitions(-DRAPIDJSON_HAS_STDSTRING) And it builds ok. The problem is that in Eclipse CDT I want…
FrameBuffer
  • 757
  • 1
  • 7
  • 26
0
votes
1 answer

rapidjson incorrect webservice string format

I have a return string from my webservice as such: std::string json_str = "{"Count":18,"Result":[{"Description":"DATABASE TASK MODE…
xinthose
  • 3,213
  • 3
  • 40
  • 59
0
votes
2 answers

std::string to const char array

This is the code I am seeking to do std::string json_str; const char json[] = json_str; this is my try const char json [json_str.size()] = {(char) json_str.c_str ()}; But it gives me the error "cast from 'const char*' to 'char' loses…
xinthose
  • 3,213
  • 3
  • 40
  • 59
0
votes
2 answers

is there special characters or strings cannot be used as key in rapidjson?

can special characters be used as a part of key? For example : { "+new":"addnew.png" "":"empty.png" } Is this format of rapidjson valid? Also, is there any special strings that is not valid to use as key? (I think the earlier question…
ggrr
  • 7,737
  • 5
  • 31
  • 53
0
votes
1 answer

How to reverse parse using rapidjson?

for example, I have a class to parse from string to object: Student.h class Student{ public: inline std::string getName(){ return this->name; } inline void setName(std::string name){ this->name=name; } inline…
ggrr
  • 7,737
  • 5
  • 31
  • 53
0
votes
2 answers

C++ rapidjson Error: free(): invalid next size (normal)

I am reading in data on JavaScript an pass the Jsonstring like that:{"data_size":500, "array":[0,0,0,0,..,0,0]} to the webserver. The numbers in the array could be anything between 0 to 4294967295. On the Mongoose webserver I am using the lib…
frank schmidt
  • 121
  • 3
  • 15
0
votes
1 answer

what is the difference between `doc.AddMember("key1",1,document.GetAllocator())` and `doc["key1"]=1`?

I want to create a json object in cocos2d-x 3.4 with rapidjson and convert it to a string: rapidjson::Document doc; doc.SetObject(); doc.AddMember("key1",1,doc.GetAllocator()); doc["key2"]=2; rapidjson::StringBuffer…
ggrr
  • 7,737
  • 5
  • 31
  • 53
0
votes
2 answers

Why linker error but not compile error when copying rapidjson::Document?

rapidjson::Document copy results to link error: Error 5 error LNK2019: unresolved external symbol "private: __thiscall rapidjson::GenericValue,class rapidjson::MemoryPoolAllocator >::GenericValue,class rapidjson::MemoryPoolAllocator >(class…
Narek
  • 38,779
  • 79
  • 233
  • 389
0
votes
1 answer

Get offset of node within rapidjson?

I am deserializing a json string into an object using rapidjson. When I encounter an issue, not with the structure of the json, but with the content, I want to report an error stating the offset of where the problem is. Unfortunately, unless…
user3072517
  • 513
  • 1
  • 7
  • 21
0
votes
1 answer

How to transition from getString rapidjson to std::string

I want to assign a string value from rappidjson to my variable class. void MyClass::setName(Ch* jsonString) { _name = (std::string)jsonString; }
Kakashi
  • 534
  • 11
  • 16
0
votes
1 answer

Conversion from 'Type (__cdecl *)(std::istream)' to 'Type &'

I have problems to understand the cause of an error when calling a template function in C++. The function in question is part from rapidjson and the definition is like: template
Constantin
  • 8,721
  • 13
  • 75
  • 126
0
votes
2 answers

Libcurl + rapidjson for Streaming Deserialization?

I have been tearing my hair out (not much to begin with, though), trying to figure out a way to hit a web service and then parse and deserialize the json in chunks while parsing at the same time into into my objects without storing the entire…
user3072517
  • 513
  • 1
  • 7
  • 21
0
votes
1 answer

RapidJson parsing array of json

What to do if I have this kind of json? I'm using rapidjson {[ { "username": "A", "level": "1", "score": "1774" }, { "username": "Ab", "level": "1", "score": "1923" }, { …
Napitupulu Jon
  • 7,713
  • 3
  • 22
  • 23
0
votes
1 answer

How got the duplicate key's value from rapidjson?

I'm new to rapidjson, and I have below json text: {"Response":"GetAllocations","ResponseCode":200,"ports":[0,1,2],"ports":[3,4,5], "ports":[6,7,8]} How could I extract the values: 0, 1, 2; 3, 4, 5; 6, 7, 8 by key "ports"? Thanks in advance.