JSON characters changed in Angular HTTP GET

I am trying to get a JSON object from a fallback service. When I connect the url to my browser (Firefox or Chrome), I get JSON with the correct UTF-8 encoding:

    {"name":"UniversitΓ©"}

      

However, when I try to GET the same URL in my Angular app, the text is not encoded correctly. This is the object printed to the JavaScript console:

    { name: "Universit "}

      

Here is the code I'm using in Angular:

  $http(

      {
        method: "GET",
        url: 'localhost:8080/my/url/location',
        headers : {

          "Accept":"application/json;charset=utf-8",
          "Accept-Charset":"charset=utf-8"

        }
      }

  ).success(function(data,status,headers,config){

    console.log(data);

    /* the rest of the success function */ 

  }).error(function(data,status,headers,config){

    /* the rest of the failure function */ 

  });

      

Any ideas? Thanks in advance!

+3


source to share


1 answer


The problem was not with the code, but that the source file for the JSON was not encoded in UTF-8



+1


source







All Articles