ios - Use Json_create always get NULL frome json-string in cocos2dx 2.2.3 -
my code @ follow
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);
the result of cclog("info: %s",infostr.c_str()); @ follow:
{ "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+" } ] }
i json* mjs null.i think string of json right.i used google can't answer. use json_create in wrong way? or other reason? lot of thank!
Comments
Post a Comment