jtyler
jtyler

Reputation: 1105

Struts 2 JSON Return back JSON array

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"
    }
]

Upvotes: 0

Views: 1778

Answers (1)

jtyler
jtyler

Reputation: 1105

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>

Upvotes: 1

Related Questions