Cannot convert to JSON object in android -


i want create android client application consume json based asmx web service asp.net server application.my server code return json fromat result . , tried sample code internet.it convenient.but own server application ("http://stockcluster.com/currentperiod.asmx/getgrowthpersentage") following error appeared instead of json object:

<html xmlns="http://www.w3.org/1999/xhtml">  <head><title></title>  <script src="http://ak2.imgaft.com/script/jquery-1.3.1.min.js" type="text/javascript"></script>  <script type="text/javascript" language="javascript">      $(document).ready(function () {      jquery.ajax({ url: 'https://mcc.godaddy.com/parked/park.aspx/?q=pfhmpjmalao4puybmzqlmf5j     labyzwmzqaryz3rlawt0zgn3zphlaza2pfhmpgrmamn2bgrkbqp0agp0awhmaqdyzwmymlhmpg     vjzgzkzqn3zqz0amzlwgv2l3xyz3rk-1', datatype: 'jsonp', type: 'get', jsonpcallback: 'parkcallback',      success: function (data) { if (data["returnval"] != null) { window.location.href = 'http://stockcluster.com?nr=' + data["returnval"]; }      else { window.location.href = 'http://stockcluster.com?hg=0' } }});}); </script></head><body></body></html>   value <html of type java.lang.string cannot converted jsonobject 

please give me suggestions.

edit: server code here :

[webmethod]     public void helloworld() {         string j = "hello world";         context.response.write(jsonconvert.serializeobject(new { j }));     } 

output json here:

{"j":"hello world"} 

i use embed google gson library in projects.

you can use following method read objects json:

type ulist = new typetoken<arraylist<yourcustomobject>>() {                 }.gettype(); arraylist<yourcustomobject> = gson.fromjson(jsonstringfromyourrequest, ulist); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -