0

It seems that the Struts 2 JSON plugin returns back a object structure ({..ect..}) as the base value by default - Is there a way to configure the struts 2 json plugin such that it returns back an array object, like so?

[
    {
    "blah1": "1",
    "blah2": "2"
    },
    {
    "blah3": "3",
    "blah4": "4"
    }
]

1 Answer 1

1

Found it! Use the root param in the xml config:

<result name="success" type="json">
        <param name="contentType">application/json</param>
        ....
        <param name="root">myArray</param>
</result>
Sign up to request clarification or add additional context in comments.

2 Comments

Exactly, because JSON Plugin serializes the entire Action ;) Read more here: stackoverflow.com/a/17149414/1654265
content type "application/json" is a default, not necessary

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.