Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify map properties in Struts 2 JSON Plugin

Tags:

json

map

struts2

I'm using Struts 2 along with the json plugin, the properties mappings in the struts.xml file are typically frustrating but I am able to figure them out.

I have come across a case where I cannot set the includeProperties to give me the result I expect.

Frequently I use a configuration expression

^itemList\[\d+\]\.id,
^itemList\[\d+\]\.name
....

This works well.

In this case I would like to return data from a Map not a list (or a map that's a child of a list member)

If a * is used the whole map is printed out correctly, but I do not want all the data from the map elements.

^itemList\[\d+\]\map\.*

The whole map is returnd

I have tried several different formats and none of them have produced results.

^itemList\[\d+\]\map\[\d+\]\.id
^itemList\[\d+\]\map\[\d+\]\.name

Nothing is returned in the map property

Anyone had any luck with a syntax to restrict the contents of a map?

Thanks -Scott

like image 934
Scott Avatar asked Nov 14 '22 17:11

Scott


1 Answers

You cannot use 'd' it map as integer. Try this ^itemList\..*$

like image 74
abhi Avatar answered Dec 09 '22 20:12

abhi