actolap / json-io

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

Feature request: add a optional fallback type parameter for the toplevel json container to JsonReader.jsonToJava(json); #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We give the possibility to specify http get parameters also as json strings, to 
allow class objects as parameter types for the web interfaces also.

The problem is, by using json-io, specifying @type in the json string is 
mandatory for deserialization, right? Thus, the users have to specify it, which 
is not so nice (for the return values its fine of course, but for parameters?)

I love the way json-io deals with types, for me, it is the best solution to 
support polymorphism I have seen in such a library. Nevertheless, in this case, 
the underlying type of the parameter normally not changes - it should be 
transparent for the (e.g. javascript) user of the interface who creates the 
json, and clear for the server.

Is it possible to add another method to JsonReader.jsonToJava(String json, 
Class toplevelFallbackType) - where toplevelFallbackType could be also String, 
Type, etc. of course.
This parameter would then be used as fallback if the @type was not specified in 
the toplevel json object.
I know this would not work with polymorphism, but it would help us a lot and 
would be maybe a nice enhanchement of json-ios functionality:)

Thanks and best regards

Christian

Original issue reported on code.google.com by christia...@gmail.com on 8 Jul 2014 at 3:44

GoogleCodeExporter commented 9 years ago
Hi, any idea if this can be implemented by forking the repo?

Original comment by dimanem...@gmail.com on 20 Apr 2015 at 1:36