Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9225721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:39:08+00:00 2026-06-18T04:39:08+00:00

I have this webservice which return a JSON array public string getLastDP(string accountID) {

  • 0

I have this webservice which return a JSON array

 public string getLastDP(string accountID)
 {
    string connectionString = ConfigurationSettings.AppSettings["connectionString"].ToString();

    MySqlConnection connectionObj = new MySqlConnection(connectionString);
    List<lastDPElements> listOFElements = new List<lastDPElements>();
    try
    {
        connectionObj.Open();

        MySqlCommand cmd = new MySqlCommand("REPORTSERVER_ALL_LAST_DP_OF_DEVICE", connectionObj);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new MySqlParameter("acc", accountID));
        MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
        while (dr.Read())
        {
            lastDPElements temp = new lastDPElements();
            temp.accountID = dr["accountID"].ToString();
            temp.address = dr["address"].ToString();
            temp.deviceID = dr["deviceID"].ToString();
            temp.displayName = dr["displayName"].ToString();
            temp.heading = double.Parse(dr["heading"].ToString());
            temp.inputMask = dr["inputMask"].ToString();
            temp.latitude = double.Parse(dr["latitude"].ToString());
            temp.longitude = double.Parse(dr["longitude"].ToString());
            temp.timestamp = Convert.ToDateTime(dr["timestamp"].ToString());
            listOFElements.Add(temp);
        }
        return new JavaScriptSerializer().Serialize(listOFElements);
    }
    catch
    {
        throw;
    }
    finally
    {
        connectionObj.Close();
        connectionObj.Dispose();
    }



}

The array returned by the service is

[{  "accountID":"rbTours",
"deviceID":"000020120504004",
"timestamp":"\/Date(1359720917000)\/",
"latitude":28.4337833,
"longitude":77.1048833,
"speedKPH":0,
"heading":130.44,
"altitude":0,
"address":"HCG CNG Station, Sector Road to Sector 56, DLF Ph. V, Gurgoan, Gurgaon, Haryana, 122002, India",
"odometerKM":null,
"displayName":"DL 1YC 7276",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"},{"accountID":"rbTours",
"deviceID":"000020120711002",
"timestamp":"\/Date(1358638851000)\/",
"latitude":28.610895,
"longitude":77.3269683,
"speedKPH":0,
"heading":253,
"altitude":0,
"address":"Gazipur Shamshan Ghat, Mayur Vihar III, Patparganj, East Delhi, National Capital Territory of Delhi, 110092, India",
"odometerKM":null,
"displayName":"DL1YC8576",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"},{"accountID":"rbTours",
"deviceID":"000020120618001",
"timestamp":"\/Date(1359721995000)\/",
"latitude":28.6345933,
"longitude":77.449505,
"speedKPH":0,
"heading":284.04,
"altitude":0,
"address":"National Highway 24 Bypass, B-Block, Lohia Nagar, Ghaziabad, Ghaziabad, Ghaziabad, Uttar Pradesh, 201001, India",
"odometerKM":null,
"displayName":"DL 1Y C6322",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"},{"accountID":"rbTours",
"deviceID":"000020120618002",
"timestamp":"\/Date(1359715788000)\/",
"latitude":28.4446867,
"longitude":77.0450667,
"speedKPH":0,
"heading":35.25,
"altitude":0,
"address":"NH8, Sec 38, Gurgoan, Gurgaon, Haryana, 122018, India",
"odometerKM":null,
"displayName":"UP16 AT 7410",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"},{"accountID":"rbTours",
"deviceID":"000020120711001",
"timestamp":"\/Date(1359693209000)\/",
"latitude":28.5384833,
"longitude":77.1915783,
"speedKPH":0,
"heading":288.26,
"altitude":0,
"address":"Aurobindo Marg, Qutab Institutional Area, Katwaria Sarai, South Delhi, National Capital Territory of Delhi, 110016, India",
"odometerKM":null,
"displayName":"UP16 AT7415",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"},{"accountID":"rbTours",
"deviceID":"356307040485566",
"timestamp":"\/Date(1359698595000)\/",
"latitude":28.5716512,
"longitude":77.136544,
"speedKPH":0,
"heading":0,
"altitude":0,
"address":"NH8, Palam, New Delhi, National Capital Territory of Delhi, 110021, India",
"odometerKM":null,
"displayName":"DL 1Y C9174",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"},{"accountID":"rbTours",
"deviceID":"000020120707001",
"timestamp":"\/Date(1359722004000)\/",
"latitude":28.6107633,
"longitude":77.327815,
"speedKPH":0,
"heading":299.16,
"altitude":0,
"address":"Sector 11, Noida, Ghaziabad, Ghaziabad, Uttar Pradesh, 201307, India",
"odometerKM":null,
"displayName":"DL 1YC 8577",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"},{"accountID":"rbTours",
"deviceID":"000020120623001",
"timestamp":"\/Date(1359722004000)\/",
"latitude":28.6425567,
"longitude":77.1736367,
"speedKPH":0,
"heading":124.77,
"altitude":0,
"address":"Patel Road, Patel Nagar, Kirti nagar, West Delhi, National Capital Territory of Delhi, India",
"odometerKM":null,
"displayName":"UP16 AT 8992",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"},{"accountID":"rbTours",
"deviceID":"000020120619001",
"timestamp":"\/Date(1359721984000)\/",
"latitude":28.43367,
"longitude":77.1048533,
"speedKPH":0,
"heading":154.8,
"altitude":0,
"address":"Centrum Plaza, Sector Road to Sector 56, DLF Ph. V, Gurgoan, Gurgaon, Haryana, 122002, India",
"odometerKM":null,
"displayName":"UP16 AT 9104",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"},{"accountID":"rbTours",
"deviceID":"000020120609005",
"timestamp":"\/Date(1359721996000)\/",
"latitude":28.6760217,
"longitude":77.2942033,
"speedKPH":0,
"heading":92.92,
"altitude":0,
"address":"National Highway 24, Shahdara, North East Delhi, National Capital Territory of Delhi, India",
"odometerKM":null,
"displayName":"DL1V A 8569",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"},{"accountID":"rbTours",
"deviceID":"000020120818004",
"timestamp":"\/Date(1359721960000)\/",
"latitude":27.1598883,
"longitude":78.0428533,
"speedKPH":0,
"heading":1.07,
"altitude":0,
"address":"The Silk Route Restaurant, SH62, Tajganj, Agra, Uttar Pradesh, 282001, India",
"odometerKM":null,
"displayName":"DL 1V A 8743",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"},{"accountID":"rbTours",
"deviceID":"000020120813001",
"timestamp":"\/Date(1359715794000)\/",
"latitude":28.613985,
"longitude":77.331255,
"speedKPH":0,
"heading":231.58,
"altitude":0,
"address":"Sector 11, Noida, Ghaziabad, Ghaziabad, Uttar Pradesh, 201307, India",
"odometerKM":null,
"displayName":"DL 1Y C6321",
"pushPinPath":null,
"temperature":null,
"inputMask":"0"}];

How can I parse it to get data in a format that I can get individual elements. I am calling the service from following script.

function getData() {
            var accountObj = 'rbTours';
            $.ajax({
                url: "Services/GetData.asmx/getLastDP",
                type: "POST",
                dataType: "json",
                data: "{accountID:'" + accountObj + "'}",
                contentType: "application/json; charset=utf-8",
                success: function(response) {
                    functionOnSuccess(response.d);
                },
                error: function(e) {
                    alert(e);
                }
            });
            return false;
        }
        function functionOnSuccess(arrayOfElements) {
        var data=[];
        if (arrayOfElements != null && arrayOfElements != 'undefined') {
        for (var i = 0; i < arrayOfElements.length; i++) {
          var row = new Array();
          row[0] = response[i].latitude;
          row[1] = response[i].longitude;              
          data.addRow(row);
          }
          }
         alert(data);
        }

What should I do on OnSuccess to get elements in an list format
I want to get the data like

var requiredValue=array[0].latitude etc

Sorry for my english..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:39:10+00:00Added an answer on June 18, 2026 at 4:39 am

    You can get the values as follows.

      function getData() {
                var accountObj = 'rbTours';
                $.ajax({
                    url: "Services/GetData.asmx/getLastDP",
                    type: "POST",
                    dataType: "json",
                    data: "{accountID:'" + accountObj + "'}",
                    contentType: "application/json; charset=utf-8",
                    success: function(response) {
                        functionOnSuccess(response.d);
                    },
                    error: function(e) {
                        alert(e);
                    }
                });
                return false;
            }
            function functionOnSuccess(arrayOfElements) {
            var data=[];
            if (arrayOfElements != null && arrayOfElements != 'undefined') {
              requiredValue=arrayOfElements[0].latitude; 
            }
    

    edit 1

    or even you can loop through your collection

       function functionOnSuccess(arrayOfElements) {
            var data=[];
            if (arrayOfElements != null && arrayOfElements != 'undefined') {
              for(i=0;i<arrayOfElements.length;i++)
              requiredValue=arrayOfElements[i].latitude; 
            }
    

    edit 2

     function functionOnSuccess(arrayOfElements) {
           obj = JSON.parse(arrayOfElements);
           alert(obj.count);
    

    and see what is there in count.

    edit 3

     function functionOnSuccess(arrayOfElements) {
           obj = JSON.parse(arrayOfElements);
           alert(obj.length);
    

    and see what is there in count.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webservice which return this kind of json object : { dossiers:
I have string that look like Array that fetched from other webservice like this
I have this url which is JSON webservice http://ws.geonames.org/weatherJSON?north=90&south=-9.9&east=-22.4&west=55.2 I need to write a
I am calling a webservice using jQuery/AJAX which returns a string array (string[]). This
I have a .net webservice which returns a Json data in this format: NSDictionary
Background: I'm invoking a web service method which returns a JSON string. This string
I have a C# WebService setup to return JSON info for use on a
I have a webservice (.NET) which returns JSON result. The iOS application consumes that
I have webservice that can return data in multiple formats. For example json and
I have created a webservice in C# which looks like this: [WebMethod] [ScriptMethod(ResponseFormat =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.