Error in C#(windows 8.1 phojne development) -
i new program language ,i can't locate problem ,i looked through of pages provided in community,but can't find solution..
here question?
i trying parse jsonarray getting webserver.. parsing code this,but gives me error mentioned below
private async void navigatebtn_click1(object sender, routede..ventargs e) { long phone = system.convert.toint64(phonenumber.text); string pwd = system.convert.tostring(password.text); uri url = new uri("http://www.example.com&phnum=" + phone + "&pass=" + pwd); system.net.http.httpclient httpclient = new system.net.http.httpclient(); var response = await httpclient.getasync(url); var result = await response.content.readasstringasync(); debug.writeline(result); login deserializeduser = readtoobject(result); frame.navigate(typeof(maps)); } } private static login readtoobject(string resul) { takeuz.login.user.rootobject obj = jsonconvert.deserializeobject<takeuz.login.user.rootobject>(resul); // deserializing // var rootobject = jsonconvert.deserializeobject<takeuz.login.user.rootobject>(); foreach (var blog in obj.user) { debug.writeline(blog.version); debug.writeline(blog.vuser); } // login deserializeduser = new login(); // memorystream ms = new memorystream(encoding.utf8.getbytes(json)); // datacontractjsonserializer ser = new datacontractjsonserializer(deserializeduser.gettype()); //deserializeduser = ser.readobject(ms) login; // ms.dispose(); //return deserializeduser; } }
my json deserializable code
class login { [datacontract] public class user { [datamember] public float version { get; set; } [datamember] public string vuser { get; set; } [datamember] public int32 id { get; set; } [datamember] public string hd { get; set;} [datamember] public string verify { get; set; } [datamember] public int32 key { get; set; } public class rootobject { public list<user> user { get; set; } // public int success { get; set; } }
and jsoncode
[{"rv":1.2,"verifieduser":"test","id":"1234","hd":"li","verify":"newuser","key":"1234"}]
it returns me error
"not code paths return value"
help me ,i'm struck in it
your method readtoobject
, should return login
, has no return
statement. it's in comment:
//return deserializeduser;
update:
the brackets of code snippet don't match. have 3 opening brackets {
, 5 closing }
. i.e. code blocks not grouped expected. can cause error.
Comments
Post a Comment