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
7
votes
4 answers

Perform a copy of Document object of rapidjson

I'm making a class and I want to return my class inside a method. My class has a rapidjson::Document object. You can see the previous problems here: LNK2019: "Unresolved external symbol" with rapidjson As I discovered, rapidjson prevent you to…
SysDragon
  • 9,692
  • 15
  • 60
  • 89
7
votes
1 answer

stringify with rapidjson

I'm using socket.io-clientpp, https://github.com/ebshimizu/socket.io-clientpp, which uses rapidjson. When a event is received, my function is called : void data_published(socketio::socketio_events&, const Value& v) { Value is a rapidjson value. My…
Robert Cervera
  • 71
  • 1
  • 1
  • 2
6
votes
1 answer

How can I keep a reference to something that gets moved?

I have something as the following using rapidjson rapidjson::Value parent; parent.SetObject(); rapidjson::Value child; child.SetObject(); parent.AddMember("child", child, document.GetAllocator()); The problem is when I call parent.AddMember(),…
Lord Nikon
  • 172
  • 8
6
votes
2 answers

How to reuse Stack Allocator in RapidJSON without reallocating memory

I'm running a single-threaded system in FreeRTOS with limited resources. I already preallocate buffers for the RapidJSON allocators as so: char valueBuffer[2048]; char …
Cigogne Eveillée
  • 2,178
  • 22
  • 36
6
votes
1 answer

how do I copy a rapidjson::value?

I'm trying to copy a rapidjson::value into a class member. error: ‘rapidjson::GenericValue >::GenericValue(const rapidjson::GenericValue >&) [with Encoding =…
user2741831
  • 2,120
  • 2
  • 22
  • 43
6
votes
1 answer

What is the difference between Document and Value in rapidjson?

Seems Document can also be used as parameter in void test(Value value); and both Document and Value can have child value, what is the difference between them?
ggrr
  • 7,737
  • 5
  • 31
  • 53
5
votes
1 answer

How can I validate a subset of a RapidJSON document?

I'm using RapidJSON to parse messages that (roughly) conform to JSON-RPC. Here's an example of one such message: { "method": "increment", "params": [ { "count": 42 } ] } The content of params depends on the value of method, so... I need to…
evadeflow
  • 4,704
  • 38
  • 51
5
votes
1 answer

Can I distinguish Integer and Double type in rapidjson

When I ask type of rapidjson::Value using GetType() method, it returns only belows Type: //! Type of JSON value enum Type { kNullType = 0, //!< null kFalseType = 1, //!< false kTrueType = 2, //!< true kObjectType = 3, …
Jason Heo
  • 9,956
  • 2
  • 36
  • 64
5
votes
5 answers

How to prevent JSON parser crashing when there are illigal characters in JSON?

Due to some communication errors, I am sometimes receiving JSON strings with some illegal characters: "{messageType\" : \"Test1\", \"from\" : \"F2D0B5C6-9875-46B5-8D4F\"}����1" These illegal characters are making my JSON parser to break. I am…
Deekshith
  • 1,544
  • 2
  • 14
  • 15
5
votes
1 answer

C++ rapidjson: GenericValue::IsNull is returning false in any case

I still shocked after detecting a mysterious issue on our project. We realized that calling HasMember("string") was performing an extra seek. So, for performance reasons, we change it. The main idea is: Instead of calling HasMember and afterwards…
dmayola
  • 502
  • 5
  • 16
5
votes
2 answers

rapidjson - change key to another value

Here is the hello world of rapidjson. How can I change key "hello" to "goodbye" and get string from the json? I mean I want to parse json, change some keys and get json string back like {"goodbye" : "world"}. const char json[] = "{ \"hello\" :…
Narek
  • 38,779
  • 79
  • 233
  • 389
5
votes
2 answers

RapidJson undefined reference

in function rapidjson::GenericDocument, rapidjson::MemoryPoolAllocator >::GenericDocument(rapidjson::GenericDocument, rapidjson::MemoryPoolAllocator >…
Arvind Kanjariya
  • 2,089
  • 1
  • 18
  • 23
5
votes
2 answers

Write in file using Rapidjson

How can i write some data into file using rapidjson document : Here is what i need to write : "Big Node ": [ { "Big Key": "Key Value 1", "Child Key": "Key Value 1", "Values": [ 1, 3, 4, 1, 2, 3 ] …
user2815841
4
votes
1 answer

std::string to rapidJson object conversion

I was trying to convert one std::string to rapidJson object in below format { "data":{ "value": "AB1234" } } I have tried rapidjson::Document…
user2235747
  • 345
  • 6
  • 14
4
votes
0 answers

RapidJSON: How to move one Document to another?

I'm trying to pass a Document as a parameter (in this case to a C++ Class C'tor, but doens't really matter), and move it, so the orig Document will become Null, and the class member will hold the document. Example: class A { rapidjson::Document…
brkeyal
  • 1,317
  • 1
  • 16
  • 22
1
2
3
25 26