Adding non string JSON properties

34 views
Skip to first unread message

Derek Gebhard

unread,
Jul 6, 2013, 4:29:46 PM7/6/13
to halbuil...@googlegroups.com
Is there any way to add non-string properties when building the HAL representation?  This throws an exception for me when trying to use a boolean for instance.

Mark Derricutt

unread,
Jul 6, 2013, 5:38:22 PM7/6/13
to halbuil...@googlegroups.com
Hi Derek,

Do you have any specific example code that shows this - this is covered by the tests already, see:

https://github.com/HalBuilder/halbuilder-json/blob/develop/src/test/java/com/theoryinpractise/halbuilder/json/RenderingTest.java#L116

for example.

        String href = "customer/123456";
        ReadableRepresentation party = newBaseResource(href)
                .withLink("ns:users", BASE_URL + href + "?users")
                .withProperty("id", 123456)
                .withProperty("age", 33)
                .withProperty("name", "Example Resource")
                .withProperty("optional", Boolean.TRUE)
                .withProperty("expired", Boolean.FALSE);
 


Derek Gebhard wrote:
Is there any way to add non-string properties when building the HAL representation?  This throws an exception for me when trying to use a boolean for instance. --

Derek Gebhard

unread,
Jul 26, 2013, 1:27:39 AM7/26/13
to halbuil...@googlegroups.com
Thanks I looks like I made a silly mistake and was using the primitive boolean type.

Mark Derricutt

unread,
Jul 26, 2013, 1:29:47 AM7/26/13
to halbuil...@googlegroups.com
Interesting - I would have thought that should have still passed as it should auto box into a Boolean object, I'll add some tests and see if/why that's happening and see about working around it if possible.
Reply all
Reply to author
Forward
0 new messages