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

How to access just added json object in rapidjson?

I want to do what I consider very basic in rapidjson. I want to start a new object and then add members to that object - but I have a hard time finding out how to do it properly. I start like this: rapidjson::Value…
2
votes
2 answers

Is this code accessing an associative array in a class in C++?

I'm looking at the rapidjson code for possible integration. I can see that thanks to the new C++11 you can in fact do associative arrays in C++, although I'm not sure the speed advantages. However, in their example code I'm seeing this: Document…
Mikey A. Leonetti
  • 2,834
  • 3
  • 22
  • 36
2
votes
1 answer

Parsing object inside array in rapidjson

I'm having problems implementing a recursive function that goes over the tree I get from the parsing of a json input. json input. e.g.: { "attr" : { "a": 1, "ovec": [ { "b": 2, "c": 3 }, { "d": 4} ] } } This is what we call a 'compound value of…
fgalan
  • 11,732
  • 9
  • 46
  • 89
2
votes
2 answers

Rapidjson findmember

I have a JSON string like this: {"callCommand":{"command":"car","floor":"2","landing":"front"}} Now, I would like to check if there is a name called command and get the value. Is it possible? My code is as follow, but it doesn't work. const char…
2
votes
1 answer

How to write a nested handler for rapidjson deserialization?

I'd like to write a nested handler for consumption of json using rapidjson. I've modeled my basic handler along the lines of the official simplereader example. This is fine for flat structures, but now I need to expand the parsing to nested objects…
conciliator
  • 6,078
  • 6
  • 41
  • 66
2
votes
1 answer

RapidJson : How to get all Key_names from a JSON? (cocos2dx)

From a Json string (or file), I want to collect key/value pairs without knowing the keys in advance. Let's say I have this Json: { "a":"1","b":"2","c":"3" } I'd like to collect all key strings "a" , "b" , "c" , "d" and their respective values. BTW:…
Zenslainer
  • 159
  • 1
  • 9
2
votes
0 answers

Rapidjson parse in chunks

I'm working on a rest client and I want to allocate everything twice. So I decided It would be good to parse directly from my read buffer when I'm sure the content is a json. My so I would like to pass a char* pointer or iterator and a size or an…
Pete
  • 179
  • 11
2
votes
1 answer

How to differentiate between key and value while parsing JSON string using rapidjson?

I'm parsing a JSON string using "rapidjson". I'm studying following example of SAX type parsing of json object. https://github.com/miloyip/rapidjson/blob/75cee948d44876f22f7215b9bd64733c3d7fee51/example/simplereader/simplereader.cpp In this SAX…
balaji
  • 1,075
  • 3
  • 12
  • 26
2
votes
2 answers

LNK2019: "Unresolved external symbol" with rapidjson

I have a Visual C++ Project in which I added the rapidjson library, which is tested to be working properly. But when I add a rapidjson::Document type to the nested class is throwing a LNK2019 error when I try to compile. The project is a dynamic…
SysDragon
  • 9,692
  • 15
  • 60
  • 89
2
votes
1 answer

rapidjson : Extract a parameter from JsonObject using rapidjson

I have a jsonObject that looks like {"Types":[{"Mtype":"text/plain","time":"Thus:24:32:02"},{"MtypeSec":"text/plain","time":"Thus:24:32:02"}]} I wanted to know how I can extract Mtype and time ? is the Types a jsonArray ??
MistyD
  • 16,373
  • 40
  • 138
  • 240
2
votes
1 answer

rapidjson SetString - GetString

I try setting a Value to string, using SetString, but when I try to get it, via GetString(), some random output shows up. Code: someDoc[someObjKey].AddMember(someStringKey.c_str(), someStringValueAFunctionReturns.c_str(),…
Hame
  • 494
  • 4
  • 18
2
votes
2 answers

Bad memory alignment iOS

I am stuck with the following crash report: Date/Time: 2013-09-12 22:39:54 +0000 OS Version: iPhone OS 6.1.3 (10B329) Report Version: 104 Exception Type: SIGSEGV Exception Codes: SEGV_ACCERR at 0xa0000008 Crashed Thread: 0 Thread 0…
Robin van Dijke
  • 752
  • 4
  • 13
2
votes
1 answer

Faster JsonCpp alternative that allows copying/mutability of Json objects?

JsonCpp is slow. And the code is pretty messy. Is there any alternative that is faster, cleaner and supports stuff like: Json::Value val, copy; val["newMember"] = 100; val["newMember2"] = "hello"; copy = val; val["newMember2"] =…
Vittorio Romeo
  • 90,666
  • 33
  • 258
  • 416
2
votes
1 answer

RapidJSON Looping through a string array?

I am using RapidJSON to parse JSON data except I can't work out how to loop through the members of: { "members":{ "0":{ "template":"this is member 1" }, "1":{ "template":"this is member 2" } } } I tried the…
user2131737
  • 21
  • 1
  • 3
2
votes
3 answers

Rapidjson output to string not working

I am trying to use rapidjson to output itself to a string to save to a database, using the following code : StringBuffer buffer; Writer writer(buffer); rest.Accept(writer); string reststring = buffer.GetString(); where rest is a…
Tom Macdonald
  • 6,433
  • 7
  • 39
  • 59