fyhack / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Not able to deserialize. #133

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using gson-1.3.jar.

I'm serializing my object using gson lib and i get the proper json string.
But while deserializing i get following exception:
Map objects need to be parameterized unless you use a custom serializer.

Here I cannot do this (what exception says) as I'm using spring mvc, and
what I'm trying to serialize is Springs ModelAndView's ModelMap class.

steps to reproduce the problem
1. put attached classes folder in classpath (classes.rar)
2. put attached jars in classpath (lib.rar)
3. And run the following code-snippet:
    Gson gson = new Gson(); 

    FileInputStream fin=new FileInputStream("c:\\mv.ser");
    ObjectInputStream oin=new ObjectInputStream(fin);
    ModelMap map=(ModelMap)oin.readObject();
    System.out.println("Map is:"+map);

    //serialize
    String jsonString=gson .toJson(map);
    System.out.println();
    System.out.println("JSOn String is :");
    System.out.println(jsonString);

    //deserialize
    ModelMap modelMap=gson .fromJson(jsonString, ModelMap.class);
    System.out.println("Map is:"+modelMap);

Please let me is it possible to deserialize this using gson-lib or do I
need to use json-lib for deserialization.

I would really appreciate if yoy reply me ASAP as we need to take decision
on which library to use.

Original issue reported on code.google.com by leenabo...@gmail.com on 7 Jul 2009 at 6:27

Attachments:

GoogleCodeExporter commented 9 years ago
deferred for a future release.

Original comment by inder123 on 29 Sep 2009 at 6:11

GoogleCodeExporter commented 9 years ago

Original comment by inder123 on 3 Nov 2010 at 12:01

GoogleCodeExporter commented 9 years ago
Maps need to be parameterized. There's no action we can take here.

Original comment by limpbizkit on 3 Nov 2010 at 4:56