http://rapidjson.org/md_doc_tutorial.html#ValueDocument
RapidJSON: Tutorial
This tutorial introduces the basics of the Document Object Model(DOM) API. As shown in Usage at a glance, JSON can be parsed into a DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON. Value & Document Each JSON
rapidjson.org
공식 참고 문서
일반 오브젝트 타입
Value MeshDesc(kObjectType);
MeshDesc.AddMember("m_ViewZ", 1.f, allocator);
MeshDesc.AddMember("m_eFormat", 0, allocator);
Array 타입
Value Meshs(kArrayType);
{
for (size_t i = 0; i < m_Meshes.size(); ++i)
{
Value MeshDesc(kObjectType);
MeshDesc.AddMember("m_iMaterialIndex", m_Meshes[i]->Get_MaterialIndex(), allocator);
Meshs.PushBack(MeshDesc, allocator);
}
}
주의 할 점이 반드시 for안에서 해당 array타입에 들어갈 객체를 만들고
for의 끝나는 시점에서 그 객체를 넣어줘야함
for밖에서 array에 들어갈 객체를 만들거나 객체 밖에서 pushBack해주면 무조건 에러 발생함
3. String 객체
Value szName;
string meshName = m_Meshes[i]->Get_Name();
szName.SetString(meshName.c_str(), (SizeType)meshName.size(), allocator);
MeshDesc.AddMember("szName", szName, allocator);
'프로그래밍 > CPP' 카테고리의 다른 글
엔진에 ENGINE_DLL까지 붙혔는데도 불안정한 형식이라면서 클래스 참조가 안되는 이유 (0) | 2023.04.08 |
---|---|
json 파일에서 string을 읽어와서 동적 char 배열에 추가시 주의점 (0) | 2023.04.02 |
구조체 안에 string을 선언 시 주의점 (0) | 2023.03.24 |
memcpy시 주의할 점 (0) | 2023.03.23 |
wstring -> string 혹은 string -> wstring으로 변경하는 방법 (0) | 2023.03.22 |