0

I am trying to parse a bad json format from a remote server that is like this:

//[
{},{} 
]

My code in AngularJS:

$http.get('http://www.example.com/badjson')
    .success(function(data) {
        console.log(data);
});

but i get Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data. I cannot get it working in Jquery with $.getJSON either. Any idea?

0

1 Answer 1

3

You need to get the raw response using the transformResponse function:

$http.get('http://www.example.com/badjson', { 
    transformResponse: function(d, h) { 
        return d; 
    }
})
.success(function(data) {
    conole.log(data);
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.