0

I have been searching and cannot seem to find a remedy. I have a url that has solely text in this format:

[ { 'string' : int } ]

but no {} around it. I am having a hard time using $http to read it in because it is incomplete and returns blanks when .get or .jsonp is used. Because it is just a list and not a JSON I am having a hard time reading it in. Is there some methodology for reading just a list in?

I have an empty JSON with this:

{'locations': //array I want to read in goes here}

I was trying to read in the text of the site and then convert it to an array after the fact. If so how do I go about that.

Peter
  • 302
  • 3
  • 16
  • we need more details (i.e. how are you making the request? how are you handling the response? - as in, code used) - HTTP requests would normally provide an HTTP response so handling your 'incomplete' JSON is not a problem (unless you are trying to parse is as JSON, which is not) - you could try reading your response as text or many other options but unless we have more specific details, I could be just guessing at what the issue might be - related: please read our [ask] page for hints on how improve this question – blurfus Jun 20 '16 at 19:19
  • 1
    What do you mean by incomplete? [ 'string': int ] is not a valid json. – Muli Yulzary Jun 20 '16 at 19:29
  • the complete JSON would look like this:

    {'locations':[{'city':'name','id':idNum}]}

    however to create that I need to pull what is just the text for the array I stated before and insert it into the JSON I just wrote
    – Peter Jun 20 '16 at 20:21
  • 1
    Use JSON and stop doing bad things – Arnaud Gueras Jun 20 '16 at 20:30
  • I am trying to convert what I have into JSON but I have to use the data given to me which comes as just an array like I wrote – Peter Jun 20 '16 at 20:32
  • What does the returned object look like when you view it in the browser? Parse that. See this: http://stackoverflow.com/a/27765419/2496266 – Chaim Eliyah Jun 20 '16 at 21:20
  • it returns two objects, both are just ' ' – Peter Jun 21 '16 at 14:19

0 Answers0