wangxiaowei0303 / rapidjson

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

new document's AddMember asserted. #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I want to create an new json document:
========================================
rapidjson::Document document;
document.AddMember<int>("int_1", 1, document.GetAllocator());
========================================
Program asserted at document.h:253
252:    GenericValue& AddMember(GenericValue& name, GenericValue& value, 
Allocator& allocator) {
253:        RAPIDJSON_ASSERT(IsObject());

I must call Parse("{}") before any AddMember() to avoid this assert.
It's corrected?

Original issue reported on code.google.com by zhangpei...@gmail.com on 11 Oct 2012 at 6:51

GoogleCodeExporter commented 9 years ago
By default, a document/value is of null type.
You need to call document.SetObject() to change it to object type, before 
adding member.

Original comment by milo...@gmail.com on 11 Oct 2012 at 7:14