使用Json_create总是在cocos2dx 2.2.3中获取NULL frome json-string

时间:2014-06-01 06:58:24

标签: ios json cocos2d-x

我的代码在后面

CCLOG("info: %s",infoStr.c_str());
const char * buf=infoStr.c_str();
cocos2d::extension::Json* mJs = cocos2d::extension::Json_create(buf);
cocos2d::extension::Json* item = Json_getItem(mJs,"results");
cocos2d::extension::Json* array1 = Json_getItemAt (item, 0);
cocos2d::extension::Json* itemNode =   Json_getItem(array1,"version");
float floatValue = itemNode->valuefloat;
CCLOG("floatValue: %f",floatValue);

CCLOG的结果(“info:%s”,infoStr.c_str());如下:

{
"resultCount": 1,
"results": [
    {
        "kind": "software",
        "features": [],
        "supportedDevices": [
            "iPhone4S",
            "iPadWifi",
            "iPadThirdGen4G",
            "iPhone5",
            "iPadMini4G",
            "iPadFourthGen4G",
            "iPodTouchThirdGen",
            "iPadThirdGen",
            "iPad3G",
            "iPhone4",
            "iPodTouchourthGen",
            "iPodTouchFifthGen",
            "iPhone-3GS",
            "iPad2Wifi",
            "iPhone5c",
            "iPad23G",
            "iPhone5s",
            "iPadFourthGen",
            "iPadMini"
        ],
        "isGameCenterEnabled": false,
        "screenshotUrls": [
            "http://a5.mzstatic.com/us/r30/Purple/v4/52/c0/e5/52c0e504-3e37-80a8-f17a-0b49bff6e63b/screen1136x1136.jpeg",
            "http://a4.mzstatic.com/us/r30/Purple6/v4/b6/8d/50/b68d500a-b84a-44fe-7fac-a055aa49e2ee/screen1136x1136.jpeg",
            "http://a5.mzstatic.com/us/r30/Purple4/v4/30/80/ab/3080ab26-fa55-a69b-480d-a57c803f3b81/screen1136x1136.jpeg"
        ],
        "ipadScreenshotUrls": [],
        "artworkUrl60": "http://a288.phobos.apple.com/us/r30/Purple6/v4/e6/89/56/e689561d-2bbc-8769-4325-b2acd91e0cf9/AppIcon57x57.png",
        "artworkUrl512": "http://a1062.phobos.apple.com/us/r30/Purple4/v4/1d/8c/2c/1d8c2c76-d441-4d3b-d43c-48e6f7aa98ad/mzl.oympcnqz.png",
        "artistViewUrl": "https://itunes.apple.com/us/artist/wei-gao/id777399907?uo=4",
        "artistId": 777399907,
        "artistName": "wei gao",
        "price": 0,
        "version": "1.0",
        "description": "description",
        "currency": "USD",
        "genres": [
            "Photo & Video",
            "Entertainment"
        ],
        "genreIds": [
            "6008",
            "6016"
        ],
        "releaseDate": "2014-01-02T23:19:32Z",
        "sellerName": "w",
        "bundleId": "D.IMyPhotos",
        "trackId": 77,
        "trackName": "ff",
        "primaryGenreName": "Photo & Video",
        "primaryGenreId": 6008,
        "formattedPrice": "Free",
        "wrapperType": "software",
        "trackCensoredName": "ff",
        "languageCodesISO2A": [
            "EN"
        ],
        "fileSizeBytes": "14",
        "sellerUrl": "http://wwww",
        "contentAdvisoryRating": "4+",
        "artworkUrl100": "http://a1062.phobos.apple.com/us/r30/Purple4/v4/1d/8c/2c/1d8c2c76-d441-4d3b-d43c-48e6f7aa98ad/mzl.oympcnqz.png",
        "trackViewUrl": "https://itunes.apple.com/us/app",
        "trackContentRating": "4+"
    }
]
}

我得到Json * mJs总是NULL。我认为json的字符串是对的。我使用谷歌但无法得到答案。 我是否以错误的方式使用Json_create?还是其他原因?非常感谢!

0 个答案:

没有答案