この特定のエラーを検索しましたが、関連する問題は見つかりませんでした。 (何RapidJSON tutorial状態以下)私はC++のプロジェクト内のファイルを.json解析するRapidjsonを使用しようとしている、これは私がそれをやっている方法ですRapidjsonがファイルを読み取っていない
:
main.cppに
#include "../include/rapidjson/document.h"
...
using namespace rapidjson;
int main() {
...
Document doc;
doc.Parse("data/entities.json");
if (doc.HasMember("DreadNought") { ... }
...
}
if文で期待される結果は、何かをWin32コンソールに出力することですが、document.h
の内部にRapidjson
アサートをスローします。
重要な点は、機能を検出してエラーが発生しないため、rapidjson
ファイルを認識していることです。私はデバッグするときしかし、それは、doc
オブジェクトがParse()
{data_={s={length=0 hashcode=0 str=0x00000000 <NULL> } ss={str=0x0124fa30 "" } n={i={i=0 padding=0x0124fa34 "" } ...} ...} }
0x0321ec30 {chunkHead_=0x00000000 <NULL> chunk_capacity_=65536 userBuffer_=0x00000000 ...}
を実行した後に含まれているものですdoc
オブジェクト内のすべてのフィールドはNULL
値を持っています。私はこれが何を意味するのか分からない限り、Parse<0>()
を試したことに注意してください。結果はまったく同じです。
イメージやその他のデータに同じパス(data/
)を使用しているため、パスの問題ではなく、見つかっています。
私がコンパイラから得た唯一の情報は、私が解読できなかったいくつかの警告です。私はそれがこの警告を読んで起こっていると思う何
1>...\include\rapidjson\encodedstream.h(88): warning C4512: 'rapidjson::EncodedInputStream<rapidjson::UTF8<char>,rapidjson::MemoryStream>' : assignment operator could not be generated
...\include\rapidjson\encodedstream.h(68) : see declaration of 'rapidjson::EncodedInputStream<rapidjson::UTF8<char>,rapidjson::MemoryStream>'
1>...\include\rapidjson\document.h(324): warning C4512: 'rapidjson::GenericStringRef<char>' : assignment operator could not be generated
...\include\rapidjson\document.h(1119) : see reference to class template instantiation 'rapidjson::GenericStringRef<char>' being compiled
1> ...\include\rapidjson\document.h(1118) : while compiling class template member function 'rapidjson::GenericMemberIterator<false,Encoding,Allocator> rapidjson::GenericValue<Encoding,Allocator>::FindMember(const char *)'
1> with
1> [
1> Encoding=rapidjson::UTF8<char>
1> , Allocator=rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>
1> ]
1> ...\include\rapidjson\document.h(1123) : see reference to function template instantiation 'rapidjson::GenericMemberIterator<false,Encoding,Allocator> rapidjson::GenericValue<Encoding,Allocator>::FindMember(const char *)' being compiled
1> with
1> [
1> Encoding=rapidjson::UTF8<char>
1> , Allocator=rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>
1> ]
1> ...\include\rapidjson\document.h(2010) : see reference to class template instantiation 'rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>' being compiled
1> ...\src\main.cpp(17) : see reference to class template instantiation 'rapidjson::GenericDocument<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>,rapidjson::CrtAllocator>' being compiled
は、それがconst char *
を受け入れないということですが、これはそれが私がリンクされ、チュートリアルで行われ、そして、彼らは他の方法を示していない方法です。
ありがとうございます。
UPDATE:
ファイルに問題がある可能性がありそうですが、私はそれについてはよく分からないし、それを回避する方法を知りません。私はVisual Studio Codeでファイルを作成して.jsonとして保存しました。Windows Explorerから同じ結果を.txtとして作成しました。私もJSON Editor Onlineからそれをダウンロードし、それが動作しませんので、私は、私はAPI Document::Parse(const char* json)
で...
Fine。ありがとう、私はそれに気付かなかった。 – jjimenezg93