If this is a cfc just return the struct and set return type to json

Paul

On 05/08/2011, at 5:55 PM, "Steve Onnis" <st...@cfcentral.com.au> wrote:

> I have some JSON data being generated via javascript which is being
> submitted to a page.  The JSON object is an array of structures and i need
> to make sure each structure in the array contains a particular value/pair
> and if it doesn't i need to insert it in.
> 
> 
> ** This is the JSON string before CF gets it **
> [{"coordinates":{"left":166,"top":236,"width":185,"height":146,"right":371,"
> bottom":407},"data":"sdfsdf"},{"coordinates":{"left":434,"top":364,"width":1
> 00,"height":50,"right":554,"bottom":439},"data":"emty"},{"coordinates":{"lef
> t":230,"top":465,"width":100,"height":50,"right":350,"bottom":540},"data":"4
> 00
> chars"},{"coordinates":{"left":663,"top":104,"width":100,"height":50,"right"
> :783,"bottom":179},"data":"no stars"}] 
> 
> This i do this to it....
> 
> notes = deserializeJSON(form.notes);
> for (n in notes) {
>    if (NOT structKeyExists(n, "uuid")) {
>        n["uuid"] = createUUID();
>        n["creator"] = "#request.currentUser.firstname#
> #request.currentUser.surname#";
>        }
>    }
> notes = serializeJSON(notes);
> 
> ** This is the JSON string after CF serializes it again **
> "[{\"coordinates\":{\"left\":166,\"top\":236,\"width\":185,\"height\":146,\"
> right\":371,\"bottom\":407},\"data\":\"sdfsdf\"},{\"coordinates\":{\"left\":
> 434,\"top\":364,\"width\":100,\"height\":50,\"right\":554,\"bottom\":439},\"
> data\":\"emty\"},{\"coordinates\":{\"left\":230,\"top\":465,\"width\":100,\"
> height\":50,\"right\":350,\"bottom\":540},\"data\":\"400
> chars\"},{\"coordinates\":{\"left\":663,\"top\":104,\"width\":100,\"height\"
> :50,\"right\":783,\"bottom\":179},\"data\":\"no stars\"}]"
> 
> It seems to be creating a "string" string and escaping everything.  What
> the!??  I need to store it as an actual JSON string without everything
> escaped.
> 
> Please don't tell me i have to strip out the "\" and quotations manually to
> get it back to what it should be....
> 
> Steve
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "cfaussie" group.
> To post to this group, send email to cfaussie@googlegroups.com.
> To unsubscribe from this group, send email to 
> cfaussie+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/cfaussie?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to cfaussie@googlegroups.com.
To unsubscribe from this group, send email to 
cfaussie+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en.

Reply via email to