0

I am beginner in hybrid Ionic App Development. I want to implement RESTful web service in my project. My json Data is:

{
    "records": [
        {
            "Name": "Alfreds Futterkiste",
            "City": "Berlin",
            "Country": "Germany"
        },
        {
            "Name": "Ana Trujillo Emparedados y helados",
            "City": "México D.F.",
            "Country": "Mexico"
        },
        {
            "Name": "Antonio Moreno Taquería",
            "City": "México D.F.",
            "Country": "Mexico"
        }]
}

Here i want to Parse this Data in Listview in ionic. I don't no how to parse data with array.Please suggest the solution or tutorials to get result.I want to show all Names in Listview. I am using this api link: http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=bertt thanks in advance.

Harshal Deshmukh
  • 1,787
  • 3
  • 14
  • 25
  • Your Ionic app won't have a webservice. The app can/will consume a webservice. Ionic is 'the cliente side' of your application. Take a look at this post: https://www.joshmorony.com/using-http-to-fetch-remote-data-from-a-server-in-ionic-2/ – Christian Benseler Jul 07 '17 at 12:02
  • Yes i want consume webservice ex: http://www.w3schools.com/angular/customers.php i want to show this data in listview. @ChristianBenseler – Harshal Deshmukh Jul 07 '17 at 12:07
  • You can follow this blog post/tutorial I have linked. It explains everything, step-by-step. – Christian Benseler Jul 07 '17 at 12:11

1 Answers1

0

Here you no need to parse the JSON data, it is already in object format.

You can use like this

 var myData = {
    "records": [
        {
            "Name": "Alfreds Futterkiste",
            "City": "Berlin",
            "Country": "Germany"
        },
        {
            "Name": "Ana Trujillo Emparedados y helados",
            "City": "México D.F.",
            "Country": "Mexico"
        },
        {
            "Name": "Antonio Moreno Taquería",
            "City": "México D.F.",
            "Country": "Mexico"
        }]
}
var record1 = myData.records[0];
var record2 = myData.records[1];
var record3 = myData.records[2];

console.log(record1)
console.log(record2)
console.log(record3)

console.log("Record 1 Data:")
console.log('\t'+"Name: "+record1.Name)
console.log('\t'+"City: "+record1.City)
console.log('\t'+"Country: "+record1.Country)

console.log("Record 2 Data:")
console.log('\t'+"Name: "+record2.Name)
console.log('\t'+"City: "+record2.City)
console.log('\t'+"Country: "+record2.Country)

console.log("Record 3 Data:")
console.log('\t'+"Name: "+record3.Name)
console.log('\t'+"City: "+record3.City)
console.log('\t'+"Country: "+record3.Country)
raj peer
  • 694
  • 6
  • 13