You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dimitris Mouchritsas <di...@eurodyn.com> on 2014/05/30 17:53:37 UTC

Skip parsing of property for json plugin

Hi all,

I'm using struts2-core 2.3.16.3 along with struts2-json-plugin and I 
have the following problem:

I have an entity bean, say Event which has the following 3 properties:
id, dateCreated and data

data is already a json string saved in the database.
e.g.:
Event data: 
{"id":1003,"username":"admin3","email":"test@example.com","lastname":"Lastname","f_user_type":1,"firstname":"Firstname","password":"fdhfdfh"}

Now in my struts2 action I have a List<Event> gridModel which I feed to 
a jquery grid.

My problem is that the data property string is being escaped, e.g:

{"JSON":"success","actionErrors":[],"actionMessages":[],"someId":"3","destination":null,"errorMessages":[],"errors":{},"fieldErrors":{},"gridModel":[{"data":"{\"id\":1,\"username\":\"admin\",\"email\":\"admin@example.com\",\"lastname\":\"Lastname\",\"f_user_type\":1,\"firstname\":\"Firstname\",\"password\":\"***\"}","dateCreated":"2014-05-30T18:15:10","id":46009},{"data":"{\"id\":1002,\"username\":\"admin2\",\"email\":\"test@example.com\",\"lastname\":\"Lastname\",\"f_user_type\":1,\"firstname\":\"Firstname\",\"password\":\"****\"}","dateCreated":"2014-05-30T18:15:10","id":46010},{"data":"{\"id\":1004,\"username\":\"admin4\",\"email\":\"test@example.com\",\"lastname\":\"Lastname\",\"f_user_type\":1,\"....


Is there any way to avoid this escaping? What alternatives do I have?
One idea is to just return a tiles plugin and create the json string by 
hand in a jsp.

 From what I've seen @JSON annotation does not have the option to skip 
escaping. This might be nice.

Regards
Dimitris

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Skip parsing of property for json plugin

Posted by Lukasz Lenart <lu...@apache.org>.
Hm... I don't see any option for now... extending annotation is a nice
thing, can you register a ticket in JIRA?


2014-05-30 17:53 GMT+02:00 Dimitris Mouchritsas
<di...@eurodyn.com>:
> Hi all,
>
> I'm using struts2-core 2.3.16.3 along with struts2-json-plugin and I have
> the following problem:
>
> I have an entity bean, say Event which has the following 3 properties:
> id, dateCreated and data
>
> data is already a json string saved in the database.
> e.g.:
> Event data:
> {"id":1003,"username":"admin3","email":"test@example.com","lastname":"Lastname","f_user_type":1,"firstname":"Firstname","password":"fdhfdfh"}
>
> Now in my struts2 action I have a List<Event> gridModel which I feed to a
> jquery grid.
>
> My problem is that the data property string is being escaped, e.g:
>
> {"JSON":"success","actionErrors":[],"actionMessages":[],"someId":"3","destination":null,"errorMessages":[],"errors":{},"fieldErrors":{},"gridModel":[{"data":"{\"id\":1,\"username\":\"admin\",\"email\":\"admin@example.com\",\"lastname\":\"Lastname\",\"f_user_type\":1,\"firstname\":\"Firstname\",\"password\":\"***\"}","dateCreated":"2014-05-30T18:15:10","id":46009},{"data":"{\"id\":1002,\"username\":\"admin2\",\"email\":\"test@example.com\",\"lastname\":\"Lastname\",\"f_user_type\":1,\"firstname\":\"Firstname\",\"password\":\"****\"}","dateCreated":"2014-05-30T18:15:10","id":46010},{"data":"{\"id\":1004,\"username\":\"admin4\",\"email\":\"test@example.com\",\"lastname\":\"Lastname\",\"f_user_type\":1,\"....
>
>
> Is there any way to avoid this escaping? What alternatives do I have?
> One idea is to just return a tiles plugin and create the json string by hand
> in a jsp.
>
> From what I've seen @JSON annotation does not have the option to skip
> escaping. This might be nice.
>
> Regards
> Dimitris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org