View Full Version : Serilize form to JSON Help

16 Aug 2007, 9:54 AM

I am building an application using struts2 and ext. I have a JSON action on the server but i want to make this action very generic and not code form attributes into the action itself. To do this, i would rather send one data string from the client and use the action as a broker to call the proper logic needed and return the appropriate response.

Is there a mechanism built into the Ext toolkit whihc lets me serialize the form into a JSON string? I did see the Ext.Ajax.serializeForm function, but this function serializes the form into an encoded url.


16 Aug 2007, 10:36 AM
After reading through the docs i found the following code to work great:

var jsonString = Ext.util.JSON.encode(form.getValues(false));

Worked like a charm!