What part do you feel is wrong to you? The change in the field name of "orders" to "order_ids", or the enclosing map which contains a "customer" entry?
On the field name problem I would suggest moving the @JsonProperty from the field itself to the getter. This is how I always code it (at least when I'm using Jackson)
And looking at your CustomerService.get(Long id) method, it appears to return a single Customer object, so I would not expect it to be enclosed in a map the way you say it should be.
--joe
[Velti]<
http://www.velti.com> Joseph Mocker | Senior Software Architect
t +1.650.566.7033 m +1.650.566.7033
e jmocker@velti.com @Mobclix<
http://twitter.com/Mobclix>
[cid:sep11118d8702]
The leading global technology provider of
mobile marketing and advertising solutions
<
http://mwc.velti.com/meet-us>
On Sep 17, 2013, at 12:53 PM, Christ BE wrote:
Here is the maven project for testing. 5 customers are create once when calling
http://localhost:8080/emberGF4/rest/customers
c:>curl -H "Accept:application/json"
http://localhost:8080/emberGF4/rest/customers
result should look like this:
{"customers":[{"id":1,"first_name":"F1","last_name":"L1","order_ids" : [1]},{"id":2,"first_name":"F2","last_name":"L2","order_ids":[]}]}
now the problem no Jackson formating on single instance of same object
c:>curl -H "Accept:application/json"
http://localhost:8080/emberGF4/rest/customers/2
result is
{"firstName":"F2","id":2,"lastName":"L2","orders":[]}
but should be
{"customer":{"id":2,"firstName":"F2","lastName":"L2","order_ids":[]}}
I did a stack trace compare between at the return of list call and 1 object and I notice there is a difference
>>> List<T> methode
CustomerService.get(List<Long>) line: 61
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 601
ContextBeanInstance<T>(AbstractBeanInstance).invoke(Object, Method, Object...) line: 46
ProxyMethodHandler.invoke(Object, Method, Method, Object[]) line: 101
CustomerService$Proxy$_$$_WeldClientProxy.get(List) line: not available
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
>>> single instance of object
CustomerService.get(Long) line: 69
CustomerService$Proxy$_$$_WeldClientProxy.get(Long) line: not available
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
Any what the problem could be
<emberGF4mvn.zip>