110
rated 0 times
[
114]
[
4]
/ answers: 1 / hits: 25228
/ 8 Years ago, sun, march 20, 2016, 12:00:00
I have a text file like the one below
id nm lat lon countryCode
819827 Razvilka 55.591667 37.740833 RU
524901 Moscow 55.752220 37.615555 RU
1271881 Firozpur 27.799999 76.949997 IN
i need to to convert to json like the format below
[{id:819827,nm:Razvilka,lat:55.591667,lon:37.740833,countryCode:RU},
{id:524901,nm:Moscow,lat:55.752220,lon:37.615555,countryCode:RU},
{id:1271881,nm:Firozpur,lat:27.799999,lon:76.949997,countryCode:IN}]
for a javascript application.
myapp.controller('TCtrl', ['$scope', '$http', function($scope, $http) {
$http.get('list.txt').success(function(data) {
$scope.todos = JSON.parse(data);
//console.log(data)
});
}]);
More From » json