RE: catching JSON parse errors

2013-04-30 Thread Jon Sawyer
So, I may be missing the obvious, but if the method's precondition is that it receives an int[], shouldn't you be doing input validation anyway? if (userData instanceof int[] ((int[]) userData.length 0) { return userData; } else { getResponse().setStatus(Status.BAD_REQUEST); } Or are

Re: catching JSON parse errors

2013-04-30 Thread Daniel Halperin
Hi Jon, In method 1, there is a need for input validation, as you say... but when there is input provided and there are parse errors, the handler simply gets a *null* argument and is not able to catch the exception. In method 2, the exception describes the parse error---which I want to feed back

catching JSON parse errors

2013-04-29 Thread Daniel Halperin
Hi, I have a resource that takes a POST request with JSON payload. Let's say it takes an *int[]*, and for our purposes simply returns it. There are (at least) two ways to do this: (1) Accept an *int[]*, letting Jackson auto-deserialize it. For echoing, return the deserialized array. @POST