Hello,
  I was wondering about how to do this, and I just saw your mail. The post
is interesting and useful, but I was wondering if it is possible to
automatice the conversion for beans. According to the documentation(
http://struts.apache.org/2.2.1.1/docs/json-plugin.html) a list of beans will
be mapped to a List of Maps. For example, let's say I receive the following
JSON into my action:

{"identifier":"name",
 "items":[
     {
     "accessLevel":"NO_ACCESS",
     "desc":"Officers",
     "name":"ECO Officer",
     "type":"ROLE"
     },{
     "accessLevel":"NO_ACCESS",
     "desc":"Publications",
     "name":"ECO Publications Manager",
     "type":"ROLE"
     ],
     "targetIdBox":17101}

    As required by the json plugin, I would need to define a
setIdentifier(String), setTargetIdBox(int), and a setItems(List<Map>). That
works correctly, but I would like to automatice the conversion from a Map to
a bean. Is it possible?

    Thanks

Jose Luis

2011/1/31 Harsh C <hchau...@gmail.com>

> Looks like this will work for me. Thanks!
>
> On Mon, Jan 31, 2011 at 4:14 PM, Johannes Geppert <jo...@web.de> wrote:
>
> >
> > for a while i wrote a blog post "How to parse a JSON Object when using
> > multiSearch for jqGrid with Java", I think you can adopt it to your
> > problem.
> >
> >
> >
> >
> http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/
> >
> >
> http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/
> >
> > Johannes
> >
> >
> > Harsh C wrote:
> > >
> > > I have been working with the Struts 2 JSON plugin and I have got it set
> > up
> > > so that I can serialize my Java beans as a JSON string and pass it
> along
> > > to
> > > the browser.
> > > Is the reverse possible using the plugin? That is, if I have a JS
> widget
> > > (Dojo, in this case) that spits out JSON, can I read in the JSON string
> > > and
> > > "de-serialize" it to a Java bean?
> > >
> > > I would appreciate it if someone could point me to a best-practice for
> > > doing
> > > so.
> > >
> > > --
> > > *Thanks,
> > > Harsh*
> > >
> > >
> >
> >
> > -----
> > ---
> > web: http://www.jgeppert.com
> > twitter: http://twitter.com/jogep
> >
> > --
> > View this message in context:
> >
> http://old.nabble.com/De-serialize-JSON-to-Action-tp30810552p30810811.html
> > Sent from the Struts - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> >
> >
>
>
> --
> *Thanks,
> Harsh*
>

Reply via email to