> -----Original Message-----
> From: Marlon Moyer [mailto:[EMAIL PROTECTED]
> Sent: Monday, December 05, 2005 7:27 PM
> To: CF-Talk
> Subject: OT: JSON
>
> I'm trying to return a structure of errors to my Ajax call. If there
> are no errors, it will return an empty structure called errors. The
> eval'ing this string "{"errors":{null}}" causes javascript to barf.
> Is this the right format for JSON to represent an empty structure?
I wouldn't think so.
Remember that JSON doesn't actually define anything really: all JSON is
normal, everyday, plain-jane JavaScript literal notation. Nothing more,
nothing less.
The braces represent an object and that's your problem. What your string is
saying is that you have an object and that object has a property called
"errors" which is also an object and THAT object has a property called
"null" which is illegal.
You can't define the "outer" name of an object in JSON (or really in
anything) since it has to be assigned to a variable in the caller but to get
close to what you want you would need something like this (this is from
memory so don't take it at face value):
{"errors":null}
or
{"errors":{}}
I think the latter is closest to what you're looking for.
Jim Davis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:226142
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54