Two Questions

85 views
Skip to first unread message

Brad Leupen

unread,
Oct 8, 2012, 12:21:59 PM10/8/12
to halbuil...@googlegroups.com
Hello!

First off, thanks for sharing this library with the community. I just started looking at it this morning (version 2.0.1 SNAPSHOT) and I had two quick questions regarding best practices.

1. I didnt see any way to inject my own Jackson Object Mapper without subclassing DefaultRepresentationFactory . Out of the box, the library was unable to serialize any of my java.util.Dates. 

2. what is the best practice for serializing a collection of Representations?

Thanks!

Brad

Mark Derricutt

unread,
Oct 8, 2012, 5:15:19 PM10/8/12
to halbuil...@googlegroups.com
Hi Brad,

#1 is something I've been thinking on lately, ideally - any changes to custom serialisation should affect both the JSON and XML representations to keep fidelity, I've just filed [1] to support serializing and maybe deserializing dates as ISO-8601, I've also added [2] to look at generic support for custom serialisation.

One of the problems I had last time I looked at this was supporting round-tripping,  i.e. going from code -> json <- code -> xml <- code -> json etc.

If there was a defined regex pattern for the reader of a custom SerDe that could be doable… This is a good time to look at it as I was hoping to actually start releasing soon :)

As for #2 and collections, so far I'm just including each collection entry as a sub resource ( thinking of renaming that to subRepresentation to match the new style of the API as well ) with the same rel, i.e.

<resource href="/customers">
  <resource rel="customer" href="/customer/1"><name>bob</name></resource>
  <resource rel="customer" href="/customer/2"><name>bob2</name></resource>
  <resource rel="customer" href="/customer/3"><name>bob3</name></resource>
  <resource rel="customer" href="/customer/4"><name>bob4</name></resource>
</resource>

From here, you just process any "customer" resources you find.  I'm not exactly sure what "best practise" is as HAL is still quite young. These could easily just be <link rel="customer"/> as well, using embedded <resource>'s however gives you the ability to also include some minimal representation of data.




--
You received this message because you are subscribed to the Google Groups "HALBuilder Development" group.
To post to this group, send email to halbuil...@googlegroups.com.
To unsubscribe from this group, send email to halbuilder-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/halbuilder-dev/-/8jv_KzOlXscJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages