i new json , wondering how pull info , put json object , read of values. json info looks this,
{ "photos":{ "page":1, "pages":1802, "perpage":100, "total":"180134", "photo": [ { "id":"8711964781", "owner":"21156896@n07", "secret":"3e24e45977", "server":"8553", "farm":9, "title":"old harbor", "ispublic":1, "isfriend":0, "isfamily":0 }, { "id":"8712680696", "owner":"21156896@n07", "secret":"fe82f8387b", "server":"8122", "farm":9, "title":"rockefeller plaza", "ispublic":1, "isfriend":0, "isfamily":0 }, .... it photo array goes on quite while. how values of "ispublic"? "secret" string because of "" , ispublic integer or boolean? have put them url link , download image.
public class readstring extends asynctask<string, integer, string>{ @override protected string doinbackground(string... flickrstring) { try { json = getvalue(); return json.getstring(flickrstring[0]); } catch (clientprotocolexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (jsonexception e) { // todo auto-generated catch block e.printstacktrace(); } return null; } @override protected void onpostexecute(string result) { // todo auto-generated method stub tvtest.settext(result); } this works strings. how farm, isfriend, isfamily, , ispublic converted string? tried else int values, made whole new class reading ints. isnt getting correct int value. have download int , convert string , change textview string of int using string.valueof(x); doing wrong?
public class readint extends asynctask<string, integer, string>{ @override protected string doinbackground(string... flickrstring) { try { json = getvalue(); int x = json.getint(flickrstring[0]); string y = string.valueof(x); return y; } catch (clientprotocolexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (jsonexception e) { // todo auto-generated catch block e.printstacktrace(); } return null; } @override protected void onpostexecute(string result) { // todo auto-generated method stub tvtest.settext(result); } } thanks!
jsonobject jobj = result.getjsonobject("photo"); jobj.getboolean("ispublic"); jobj.getint("isfriend"); the variable result of typejsonobject should contain entire object have pasted above in code
Comments
Post a Comment