Hi Saloranta and everybody,
After setting init-param in jersey sevlet, the prefix has been removed,
it's useful.
<servlet>
<servlet-name>Jersey Spring Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
But, at the same time, the json structure has been changed as the below
tables show, and our project is not a new one, so, we cannot accept this
solution.
When we use the above setting, we will meet the obj.length==null,
which equivalent of NullPointException error in xxx.abc line.
Would you kindly please tell me how to solve this issue?
before setting the init-param in jersey servlet**
after setting****
{ "elementList" :****
{ "*abc*" : [****
{ "@id" : "1",****
"@name" : "name1",****
"@value" : "value1"****
},****
{ "@id" : "2",****
"@name" : "name2",****
"@value" : "value2"****
},****
{ "@id" : "3",****
"@name" : "name3",****
"@value" : "value3"****
}****
]****
}****
}****
{ "elementList" :****
[****
{ "id" : 1,****
"name" : "name1",****
"value" : "value1"****
},****
{ "id" : 2,****
"name" : "name2",****
"value" : "value2"****
},****
{ "id" : 3,****
"name" : "name3",****
"value" : "value3"****
}****
]****
}
Thanks a lot!
BR,
Lu Han
2012/8/20 Eric Han <feuyeux_at_gmail.com>
> Thanks a lot and I got the desired answer!
> http://jersey.java.net/nonav/documentation/latest/user-guide.html#d4e8
>
>
> 2012/8/20 Tatu Saloranta <tsaloranta_at_gmail.com>
>
>> On Sun, Aug 19, 2012 at 6:32 AM, <feuyeux_at_gmail.com> wrote:
>> > I just encountered an issue in my working, which is jersey(JSR311)
>> > always puts prefix @ to attribute from java to json
>>
>> Keyword to look for is "POJO mapping": i.e. change the way Jersey does
>> its JSON handling.
>> That at sign is used by backends that rely on XML-to-JSON conversion,
>> and is to be avoided. It is only default due to historical reasons
>> (first JSON backend that was added I think).
>>
>> -+ Tatu +-
>>
>
>