1

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Beautiful, @JSON(name="class") over the setter worked. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.