Question

I have a pre defined json that has the following variable assigned to a JSON Object:

{
    ....
    "class": "P"
    ....
}

Trouble is, I'm using the Struts 2 JSON plugin and the following code:

private String class

is not allowed, since class is a reserved keyword. Does anyone know of a way to override the variable names in Struts 2's JSON plugin?

Was it helpful?

Solution

You can use getClass() instead, also there's @JSON annotation where you can specify name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top