Liad Livnat
Liad Livnat

Reputation: 7475

$http service throw exception when downloading json file from server

When trying to download a file from server i use $http service as following:

$http({url: url, method: "GET", withCredentials: true});

for some unkown reason only json files causing an exception when getting from server:

SyntaxError: Unexpected token ] in JSON at position 1362
    at Object.parse (native)
    at tc (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:14:245)
    at bc (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:77:7)
    at https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:77:369
    at q (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:7:322)
    at dd (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:77:351)
    at c (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:78:495)
    at https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:112:182
    at m.$eval (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:126:250)
    at m.$digest (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:123:365)

The json file is valid, i attached him in the question.

if it's a text file, or even the same file that i added a comment above the json, there is no exception.

If anyone have an idea why do i get this error, it will really really help :)

Thanks

not working file:

{
  "users": [
    {
      "email": "[email protected]",
      "nickName": "D_user1e2e"
    }
  ],
  "groups": [
    {
      "name": "D_BETWEEN_INSTANCES",
      "description": "GROUP OF USERS FROM ALL INSTANCES",
      "members": [
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]"
      ]
    },

  ]
}

working file:

tests
 {
  "users": [
    {
      "email": "[email protected]",
      "nickName": "D_user1e2e"
    }
  ],
  "groups": [
    {
      "name": "D_BETWEEN_INSTANCES",
      "description": "GROUP OF USERS FROM ALL INSTANCES",
      "members": [
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]"
      ]
    },

  ]
}

Upvotes: 1

Views: 51

Answers (1)

The scion
The scion

Reputation: 972

Remove the , sign from here-

"[email protected]"
      ]
    },

like this-

"[email protected]"
      ]
    }

Upvotes: 1

Related Questions