Closed GoogleCodeExporter closed 9 years ago
Thanks for the feedback.
1)
We are not currently considering using properties without @Key. But it is
worth filing a feature request on the HTTP project:
http://code.google.com/p/google-http-java-client/issues/entry?template=Request%2
0a%20feature
I'm not sure if we want to support it though, because then you need an
annotation to specify what you want to exclude, and then you are back to the
same problem. But I suppose that for the simple use case where you just want
to serialize all fields, it would be sufficient.
2)
We are actually investigating the possibility of polymorphic types here:
http://code.google.com/p/google-http-java-client/issues/detail?id=173
3)
I am not sure I understand your request. Normally you'd just do something like:
class Response {
@Key User user;
@Key Message message;
}
Would that suffice?
Original comment by yan...@google.com
on 19 Jan 2013 at 2:54
Thanks for the response.
1) Honestly, the Key annotation is not a huge deal for me. I was just
wondering if you guys were thinking about it. I do agree that not having them
would essentially yield the same problem.
2) Great. I've worked with both approaches (gson style on Android) and the
jackson JsonTypeInfo on the the server rest api so either of these approaches
will work well.
3) So this is exactly what I was thinking. I had to do this in order to get the
lib to parse our responses. I simply wanted to avoid having to write a bunch of
response classes for all the different objects that are returned from the API.
Right now, I'd have to write about 35 response classes to use the parseAs
method. It would be nice if you could configure this somehow without having to
write classes for it. This might even be done with annotations or a builder
type of pattern:
// ignore the bad naming ... mental block at the moment
ex.
@Key("user")
public class User { @Key private UUID id; /* more stuff here */ }
Then the parser might look parse keys the way it does for @Key on properties
and know to parse and json objects with key "user" using User.class
The other approach might be
JsonFactory jsonFactory = new JacksonFactory()
.withClassForKey(User.class, "user")
.withClassForKey(AccountSettings.class, "accountSettings")
.withParserForKey(new PolymorphicMessageParser(), "message");
That's just a rough idea, but I'm sure you guys have better solutions.
Thanks for your time
<adrian />
Original comment by adr...@teamhallo.com
on 22 Jan 2013 at 7:47
If you don't mind, I'll drop #1 only because it is something we had debated
early on when we first designed the system and came to the conclusion that
requiring @Key was the best way to go.
So I'll narrow down scope of this feature request to #3. I'm still not clear
on what you are trying to achieve. Is this perhaps a case of data wrapping
that is perhaps best solved with this:
https://code.google.com/p/google-http-java-client/issues/detail?id=164
Original comment by yan...@google.com
on 24 Jan 2013 at 2:05
Yes I have no problem with dropping #1. I just looked at issue 164 and that's
definitely what I wanted. Wrapped data like that makes it really easy for iOS
and Mac apps to consume with Key-Value Coding as seen here
https://github.com/RestKit/RestKit/wiki/Object-mapping and eliminates the need
to create a lot of wrapper classes. Thanks for you help and I'm looking forward
to this!
Original comment by adr...@teamhallo.com
on 24 Jan 2013 at 8:19
Thanks for the feedback!
Original comment by yan...@google.com
on 26 Jan 2013 at 5:12
Original issue reported on code.google.com by
oGL...@gmail.com
on 18 Jan 2013 at 10:30