Rapidjson android错误 - 断言“IsString()”失败'

时间:2017-08-27 04:55:26

标签: android c++ json cocos2d-x

我从服务器获得响应并且能够在ios模拟器中运行时能够成功解析数据但是当我在Android设备上运行应用程序时关闭msg“不幸的是app已停止”

这是我得到的错误日志 -

(22798): Abort message - /Users/mihir/Desktop/test/proj.android/../cocos2d/external/flatbuffers/../json/document.h:1681: const Ch* rapidjson::GenericValue<Encoding, Allocator>::GetString() const [with Encoding = rapidjson::UTF8<>; Allocator = rapidjson::MemoryPoolAllocator<>; rapidjson::GenericValue<Encoding, Allocator>::Ch = char]: assertion "IsString()" failed'

这是我的rapidjson解析代码 -

    if (response->isSucceed()) {
    log("Get success");

    std::vector<char>* buffer = response->getResponseData();
    std::string res;
    res.insert(res.begin(), buffer->begin(), buffer->end());
    log("res: %s", res.c_str());

    rapidjson::Document d;
    d.Parse<0>(res.c_str());
    if(d.IsObject()){


        F = d["F"].GetString();
        W = d["W"].GetString();
        T = d["T"].GetString();
        Fp = d["Fp"].GetString();
        Wp = d["Wp"].GetString();
        Tp = d["Tp"].GetString();

 }

任何帮助都将不胜感激。谢谢...

这是我的登录android -

res: {"F":null,"W":null,"T":null,"Fp":null,"Wp":null,"Tp":null,"msg":"Invalid","sid":null}

在Ios Simulator中 -

res: {"F":"135","W":"1","T":"1","Fp":"1","Wp":"1","Tp":"1","msg":"success","sid":"1nf9ecj3j2nmm2lmamblf27n34"}

相同的服务器代码在ios模拟器中返回成功,并通过android ..

无效

我回复$ _SESSION ['sid']我在下一页通过登录设置,但我在Android设备中收到null但在ios中它收到存储的会话ID,那是怎么回事?

0 个答案:

没有答案