Integrating with Jackson's Views

23 views
Skip to first unread message

Ben Kuhl

unread,
Jul 12, 2013, 4:05:34 PM7/12/13
to portal_...@googlegroups.com
Is it possible to use Jackson's view functionality using annotations in accordance with this library?

For instance, is it possible to do something like...

    @JsonView(Views.DefaultView.class)
    public static Room send(String event, Object data) {
        return room.send(event, data);
    }


Donghwan Kim

unread,
Jul 13, 2013, 1:54:08 AM7/13/13
to portal_...@googlegroups.com
I've never seen that annotation and didn't do special treatment for that. what does it do?

-- Donghwan

Ben Kuhl

unread,
Jul 15, 2013, 11:59:33 AM7/15/13
to portal_...@googlegroups.com
@JsonIgnore in Jackson is a global ignore annotation, so Jackson will always ignore the property or method that annotation is on.  A view is a way of hiding specific fields under different circumstances.  Here's the docs on it: http://wiki.fasterxml.com/JacksonJsonViews

Donghwan Kim

unread,
Jul 15, 2013, 12:19:42 PM7/15/13
to portal_...@googlegroups.com
Actually, Jackson is internally used to serialize/deserialize string to json. I haven't tried but you may be possible to use those annotations to pojos not handlers. There is no guarantee that Jackson's annotations are supported yet publicly, but options for serialization/deserialization like inbound/outbound on browser side will be provided someday. So, try it out and let me know how it goes.


On Tue, Jul 16, 2013 at 12:59 AM, Ben Kuhl <ben...@gmail.com> wrote:
@JsonIgnore in Jackson is a global ignore annotation, so Jackson will always ignore the property or method that annotation is on.  A view is a way of hiding specific fields under different circumstances.  Here's the docs on it: http://wiki.fasterxml.com/JacksonJsonViews

--
You received this message because you are subscribed to the Google Groups "Portal" group.
To unsubscribe from this group and stop receiving emails from it, send an email to portal_projec...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ben Kuhl

unread,
Aug 29, 2013, 12:37:16 PM8/29/13
to portal_...@googlegroups.com
Sorry I forgot to update this thread... Jackson Views work great out of the box.  I'm using them to send requests and replying to requests.

    @On
    @Reply
    @JsonView({Views.ManagerView.class})
    public Dashboard getDashboard(@Data String uuid) {
        Workflow workflow = WorkflowService.getWorkflow(uuid);
        return new Dashboard(workflow);
    }
Reply all
Reply to author
Forward
0 new messages