4

I am trying to preload some data using the angular-ui-router resolve method. I am getting the data back from my cfc, but the data being return isn't in a correctly formatted JSON.

Here is the actual data, just junk data right now. Also the white space preceding the json isn't showing up:

    "[{\"category_id\":1,\"name\":\"etsaaf\"},{\"category_id\":2,\"name\":\"test2\"},{\"category_id\":3,\"name\":\"test3\"},{\"category_id\":4,\"name\":\"testadsfa\"},{\"category_id\":5,\"name\":\"rob\"},{\"category_id\":6,\"name\":\"teadgafd\"},{\"category_id\":7,\"name\":\"asdfasd\"}]

I ran into the \" issue before, and it was setting the return type to json and using the serializejson method in the cfreturn call. I'm not using either, but I am using the iknowkungfoo array collection cfc to properly format my json.

I fixed the issue, by <cfreturn deserializeJSON(response)/>. Could someone shed some light on why they string was getting serialized twice? But all the extra white space is still here.

Fergus
  • 2,821
  • 2
  • 27
  • 41
Rob M
  • 1,007
  • 2
  • 17
  • 38
  • Not related to AngularJS, I've removed the tag. The problem is clearly you're serializing an already serialized string, but I can't help you more, I don't know anything about ColdFusion. – Blackhole May 12 '14 at 20:53
  • Are you using a returnformat="json" in your CFC? I recently had a similar issue and this fixed it for me. – WillardSolutions May 12 '14 at 20:57
  • @ChrisWillard I have had that issue before as I mentioned above, but I'm not doing this time. – Rob M May 12 '14 at 20:58
  • 1
    post your cfc, the url you're posting to, and check Application.cfc's onCFCRequest() (if any) – Henry May 12 '14 at 23:30
  • 2
    When you make the remote call from Angular, simply add `reurntformat=json` to the URL and simply return `response`. If you do not wish to do that, add `output="false"` to the function definition of the CFC definition and/or turn on whitespace management in Cf Administrator – Scott Stroz May 13 '14 at 01:45
  • @rob, just fyi you misspelled deserializeJSON. I edited your question – Fergus Mar 01 '16 at 01:40

0 Answers0