-1

i have problems i am searching and cant understand what type of json parser i can use for example i have local json and i want to prase it is there any sdk i can use near the newsoft json or ez to learn because i am windows phone and 8.1 developer and i sucks with android and i really need it for graduation project i created almost every thing

[
{
    "id": 1,
    "time": 40,
    "srcLong": 35.909124,
    "srcLat": 31.973628,
    "destLong": 35.898258,
    "destLat": 31.985622,
    "subSites": [
        {
            "id": 1,
            "name": "location 1"
        },
        {
            "id": 2,
            "name": "location 2"
        },
        {
            "id": 3,
            "name": "location 3"
        }
    ]
}]

plz how to get the response for example the code in newsoft json is like this

var serviceUri = "http://localhost:24728/api/sites";
HttpClient client = new HttpClient();
var response = await client.GetAsync(serviceUri);
var datafile = await response.Content.ReadAsStringAsync();
RootObject data = JsonConvert.DeserializeObject<RootObject (((string)datafile).Substring(1, ((string)datafile).Length - 2));

and of course you create the class to deal with object plz can some one help me with this and i need to remove the [] to be json object i just need the sdk i should use and where to start learn and if there no problem to tell me how to substring it and to put this code

string uri = "http://localhost:24728/api/sites/1";
HttpResponseMessage response2 = await client.PutAsJsonAsync(uri, data);

plz is there any equivalent in android.

Regards, Ayesh.

Joey
  • 1,349
  • 14
  • 26
  • Sorry am confused a bit, so you are just attempting to remove the [] from your string json Array? And something from the sdk? – Ashley Alvarado Aug 26 '15 at 19:07
  • Is there any thing equivalent to get json and post jon to URL ?? i dont know how to get data and post data in android – ayesh jamal Aug 26 '15 at 19:12
  • The code above are in C# and newsoft json sdk and thats how you get the response in that library i am stuck at getting the response in android i dont know how. – ayesh jamal Aug 26 '15 at 19:16

1 Answers1

0

Well from what you are saying it looks like you are unsure of how to get a response from the site, maybe you do not understand how to access the url initially. Or potentially that once you get the response and it is prehaps a string you do not know how to convert it into JSON to extract the information. Send information from android application to a Web Service and back. This link has a basic version of connecting to a url. And when you have a string, you can use JSONObject and JSONArrays to grab the information on that string, you can do JSONArray(string).

Community
  • 1
  • 1
Ashley Alvarado
  • 1,078
  • 10
  • 17