Thanks Tatu.
Unfortunately, I wouldn't be able to use the POJO mapping, since I use a
lot of JAXB annotated beans, and Jackson doesn't understand these
annotations, gives some errors at runtime.
On Sat, Nov 17, 2012 at 12:59 AM, Tatu Saloranta <tsaloranta_at_gmail.com>wrote:
> On Fri, Nov 16, 2012 at 6:34 AM, Srinivas Naresh Bhimisetty
> <shri.naresh_at_gmail.com> wrote:
> > Hello people,
> >
> > I have been struggling with the following problem for the last few
> hours:
> >
> > Problem Statement:
> > -----------------------------
> > Send a Java Map as a JSONObject with the keys being the map keys and
> > values being the map values, i.e., lets say, if I have the following map:
> >
> > Map<String, String> deleteme = new HashMap<String,
> > String>();
> > deleteme.put("ab","32");
> > deleteme.put("fd","d");
> >
> > I would like to send this object as : {deleteme:{"ab":"32", "fd":"d"}}
>
> Why not as
>
> { "ab" : "32", "fd":"d"}
>
> which is the natural way to map it as JSON?
>
> Adapter approach is also unnecessary when using POJO mapping: adapters
> are only needed with XML (or JSON produced via libraries that emulate
> XML API, like Jettison).
>
> With POJO mapping, it would just work; and if you actually want
> wrapping, you could use class
>
> public class DeleteMe {
> public Map<String,String> delete;
> }
>
> to get that "deleteme" added if there is need for it.
>
> -+ Tatu +-
>