struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ozu Natsu <ozu.na...@gmail.com>
Subject Re: Modify JSON Format?
Date Wed, 23 Jun 2010 18:15:01 GMT
Any example of how to do option #2?

--
Michael Griffith
Managing Partner, OpenPrinciple Consulting, LLC.
http://www.openprinciple.com

On Jun 23, 2010, at 12:21 AM, Rahul Mohan <rahul.mohan@tcs.com> wrote:

> Hi,
>
> I don't think the plugin has any option like that.  But, even if you
> manage to do that how will you ensure that the order of data  
> returned will
> match the order
> of grid columns on the client?
>
> You have two options:
> 1. Use a List of List on your action class itself so that the order is
> preserved.  The json plugin serialized an Iterable into a JSON array  
> and a
> bean to { name: value,..... } structure. So you will end up having the
> array of array in your JSON as well.
>
> 2. Post process the JSON data on your ajax callback function before
> feeding it to the table. (You also have the order available on  
> client from
> the table declaration, so it should be easy. )
>
> Regards,
> Rahul Mohan
>
>
>
>
> From:
> Ozu Natsu <ozu.natsu@gmail.com>
> To:
> Struts Users Mailing List <user@struts.apache.org>
> Date:
> 22-06-2010 20:57
> Subject:
> Modify JSON Format?
>
>
>
> Hi,
>
> I am using JSON plugin to return data to JQuery DataTable, but format
> is not compatible with Datatable plugin. I have a collection with a
> getter function on my struts2 action that is annotated with @JSON
> annotation.  The action returns an array of objects, such as:
>
> {"aaData":[",{"age":2,"breed":"Unkown","gender":"Female","id": 
> 2,"name":"Snowflake
> 2"}, ...}
>
> when what I really wany is an array of arrays:
>
> aaData: [
> [ 2, Unknown, Female, 2, Snowflake 2 ],
> [ ...] ]
>
> As I understand it, both forms of the notation are valid. Is there any
> way to configure the plug in to modify the style/format of JSON to
> render the array of arrays without hand rolling my own function to
> return the data in a string?
>
> Using struts 2.1.8.1
>
> Thank you.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message