Domanda

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"
    }
]
È stato utile?

Soluzione

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>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top