khoarus / rapidjson

Automatically exported from code.google.com/p/rapidjson
MIT License
0 stars 0 forks source link

demo request #8

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi folks:

I am trying to use rapidjson to get two value pairs unknown from a server. I 
mean sort like { "x":"y" } both x and y unknown (several of this pairs) and I 
couldn't find a demo to do that in rapidjson. I need to get/print both values. 
I think it would be great to have one around in the examples. All I could see 
are, getting predetermined values and some sort of iterators that are not easy 
to get. I mean to understand.

Original issue reported on code.google.com by waldoalv...@gmail.com on 13 Jan 2012 at 4:07

GoogleCodeExporter commented 8 years ago
Sorry that examples are insufficient at the moment. 

I think line 483-493 of 
http://code.google.com/p/rapidjson/source/browse/trunk/test/unittest/valuetest.c
pp

may do what you need:

        // member iterator
        Value::MemberIterator itr = x.MemberBegin(); 
        EXPECT_TRUE(itr != x.MemberEnd());
        EXPECT_STREQ("A", itr->name.GetString());
        EXPECT_STREQ("Apple", itr->value.GetString());
        ++itr;
        EXPECT_TRUE(itr != x.MemberEnd());
        EXPECT_STREQ("B", itr->name.GetString());
        EXPECT_STREQ("Banana", itr->value.GetString());
        ++itr;
        EXPECT_FALSE(itr != x.MemberEnd());

Basically if x is an object type value, then you can iterate it with the 
iterators returned by MemberBegin() and MemberEnd(). And then you can access 
the name and value of each member via the iterator.

Original comment by milo...@gmail.com on 31 Jan 2012 at 7:47

GoogleCodeExporter commented 8 years ago
I was also stuck at this issue. Hope you add it soon to the tutorial example.
Thanks for such a great parser!

Original comment by niranjan...@gmail.com on 8 May 2012 at 4:04

GoogleCodeExporter commented 8 years ago

Original comment by milo...@gmail.com on 14 Nov 2012 at 2:54

GoogleCodeExporter commented 8 years ago

Original comment by milo...@gmail.com on 20 Jun 2014 at 8:28