You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jo...@noaa.gov on 2009/05/21 23:38:09 UTC

JSON plugin ignoring includeProperties parameter

Hello All,

I'm trying to use jsonplugin 0.32 w/ struts 2.0.14 and it seems that the
includeProperties parameter is being ignored.  My configuration looks like:

         <result type="json">
            <param name="excludeNullProperties">true</param>
            <param name="includeProperties">
            items.*\.name
            </param>
         </result>

Can someone please help me w/ what might be wrong?

Thanks!

--john



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by John Cartwright <Jo...@noaa.gov>.
Thanks for the suggestion Dale, but removing the whitespace does not 
seem to make a difference.

--john


Dale Newfield wrote:
> John.C.Cartwright@noaa.gov wrote:
>>             <param name="includeProperties">
>>             items.*\.name
>>             </param>
>
>> Can someone please help me w/ what might be wrong?
>
> Maybe the whitespace?  Does it behave any differently if you do:
>
> <param name="includeProperties">items.*\.name</param>
> ?
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by Dale Newfield <da...@newfield.org>.
John.C.Cartwright@noaa.gov wrote:
>             <param name="includeProperties">
>             items.*\.name
>             </param>

> Can someone please help me w/ what might be wrong?

Maybe the whitespace?  Does it behave any differently if you do:

<param name="includeProperties">items.*\.name</param>
?

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by Dave Newton <ne...@yahoo.com>.
John Cartwright wrote:
> Thanks for your suggestion Andras.  Strangely that approach is not 
> working for me.  Ideally, I'd like to have the option of different 
> fields included for different actions w/ in the same package.

You can do that by configuring the interceptor on a per-action basis:

<action ...>
   <interceptor-ref name="your-stack">
     <param name="json.excludeProperties">the value</param>
   </...>
</...>

Assuming the excludeProperties stuff works at all, of course.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by John Cartwright <Jo...@noaa.gov>.
Thanks for your suggestion Andras.  Strangely that approach is not 
working for me.  Ideally, I'd like to have the option of different 
fields included for different actions w/ in the same package.

--john

Andras Balogh wrote:
> Hi John,
>
> I had the same problem with excludeProperties, what worked for me is 
> to add the param to the
> interceptor-ref tag and NOT to the result:
>
> <interceptor-ref name="json" >
>  <param name="enableSMD">true</param>
>  <param name="excludeProperties">
>   .*Collection
>  </param>
> </interceptor-ref>
>
> Best regards,
> Andras.
>
> John.C.Cartwright@noaa.gov wrote:
>> Hello All,
>>
>> I'm trying to use jsonplugin 0.32 w/ struts 2.0.14 and it seems that the
>> includeProperties parameter is being ignored.  My configuration looks 
>> like:
>>
>>          <result type="json">
>>             <param name="excludeNullProperties">true</param>
>>             <param name="includeProperties">
>>             items.*\.name
>>             </param>
>>          </result>
>>
>> Can someone please help me w/ what might be wrong?
>>
>> Thanks!
>>
>> --john
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>   
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by Andras Balogh <an...@reea.net>.
Hi John,

I had the same problem with excludeProperties, what worked for me is to 
add the param to the
interceptor-ref tag and NOT to the result:

<interceptor-ref name="json" >
  <param name="enableSMD">true</param>
  <param name="excludeProperties">
   .*Collection
  </param>
</interceptor-ref>

Best regards,
Andras.

John.C.Cartwright@noaa.gov wrote:
> Hello All,
>
> I'm trying to use jsonplugin 0.32 w/ struts 2.0.14 and it seems that the
> includeProperties parameter is being ignored.  My configuration looks like:
>
>          <result type="json">
>             <param name="excludeNullProperties">true</param>
>             <param name="includeProperties">
>             items.*\.name
>             </param>
>          </result>
>
> Can someone please help me w/ what might be wrong?
>
> Thanks!
>
> --john
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by Gadbury <ga...@googlemail.com>.
Hi new2struts,

Thank you very much for your time, investigation and explanation.  This is
very useful to know.

All the best,

James.
-- 
View this message in context: http://old.nabble.com/JSON-plugin-ignoring-includeProperties-parameter-tp23660860p27511971.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by new2struts <me...@gmail.com>.
Since no one seems to have posted an answer anywhere (and this exact same
problem stumped me for a while), I thought I'd share what worked for me.

I loaded the jsonplugin code and figured out what I needed to do to use the
"includeProperties" param to only serialize a certain property of my list. 
It seems that you also need to include the parent objects in your
includeProperties parameters.

Using your Map below, if you only wanted to serialize "myProperty" member of
your map, your includeProperties would look something like:


  productCategoriesMap,
  productCategoriesMap\[\d+\],       <--- in this case, the index is an
integer, but yours might be a string
  productCategoriesMap\[\d+\].myProperty


While stepping through the code, I found that as the jsonplugin is walking
the object hierarchy, it starts at the parent, which is
"productCategoriesMap."  It will then look to see if it should include this
property -- unless you have a rule in there to allow this, it won't continue
walking productCategoriesMap to get to "myProperty," which is why when you
only specify a rule for productCategoriesMap\[\d+\].myProperty, it
serializes nothing.  

Hope this helps!


Gadbury wrote:
> 
> The first regex returns nothing and the second everything (as before).  My
> regex is pretty poor but if I ignore regex, what would the syntax be for
> accessing the property of a bean is a list in the map.  i.e. given the
> map:
> 
> private Map<String, List<Category>> productCategoriesMap
> 
> Would it be:
> 
> myMap['myKey'].beanProperty    
> myMap.myKey.beanProperty      
> 
> or both, I seem to recall?
> 
> Is it definitely possible to filter out properties of beans within a map
> using 0.33 / 0.34 (I've tried both) of the json plugin?
> 
> Sorry to go on aout this - it's been driving me crazy all day :)
> 
> 
> Musachy Barroso wrote:
>> 
>> Java regexes are greedy by default if I dont remember wrong, so you
>> should try something like:
>> 
>> productCategoriesMap[.*?]\.name
>> 
>> or
>> 
>> productCategoriesMap\..*?\.name
>> 
>> musachy
>> 
>> On Tue, Sep 1, 2009 at 6:15 AM, Gadbury<ga...@googlemail.com> wrote:
>>>
>>> Hi,
>>>
>>> Sorry to jump a (dead?) thread but it's relevant to what I am trying to
>>> do
>>> and it made sense to put it in the same thread.
>>>
>>> I have the following HashMap:
>>>
>>> private Map<String, List<Category>> productCategoriesMap;
>>>
>>> in my includeProperties, productCategoriesMap.* populates the json with
>>> every property of the Category bean.  For example:
>>>
>>>        {
>>>        "productCategoriesMap":{"ac80e9b6-29e6-4f00-9410-1a18a9dfd317":[{
>>>                "UUID":"4bd497a1-bd1b-417b-8d62-e1273fa5e648",
>>>                "name":"Test Sub-Category EDIT",
>>>              
>>>  "parentCategoryUUID":"65750a38-d596-48d7-a215-56bcb21d8067",
>>>              
>>>  "providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
>>>                },{
>>>                "UUID":"65750a38-d596-48d7-a215-56bcb21d8067",
>>>                "name":"Category 4",
>>>              
>>>  "parentCategoryUUID":"98e4b067-5b6b-4777-a28a-443a77209948",
>>>              
>>>  "providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
>>>                }]
>>>        }
>>>
>>> However, I would like to only include UUID and name, as an example.  I
>>> have
>>> tried:
>>>
>>> productCategoriesMap.*.name
>>> productCategoriesMap.*.*
>>> productCategoriesMap[*].name
>>> productCategoriesMap.*\.name
>>> productCategoriesMap\.*\.name
>>>
>>> How do I use includeProperties to filter properties of beans within a
>>> map?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/JSON-plugin-ignoring-includeProperties-parameter-tp23660860p25240134.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>> 
>> 
>> 
>> -- 
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/JSON-plugin-ignoring-includeProperties-parameter-tp23660860p27471936.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by Gadbury <ga...@googlemail.com>.
The first regex returns nothing and the second everything (as before).  My
regex is pretty poor but if I ignore regex, what would the syntax be for
accessing the property of a bean is a list in the map.  i.e. given the map:

private Map<String, List<Category>> productCategoriesMap

Would it be:

myMap['myKey'].beanProperty    
myMap.myKey.beanProperty      

or both, I seem to recall?

Is it definitely possible to filter out properties of beans within a map
using 0.33 / 0.34 (I've tried both) of the json plugin?

Sorry to go on aout this - it's been driving me crazy all day :)


Musachy Barroso wrote:
> 
> Java regexes are greedy by default if I dont remember wrong, so you
> should try something like:
> 
> productCategoriesMap[.*?]\.name
> 
> or
> 
> productCategoriesMap\..*?\.name
> 
> musachy
> 
> On Tue, Sep 1, 2009 at 6:15 AM, Gadbury<ga...@googlemail.com> wrote:
>>
>> Hi,
>>
>> Sorry to jump a (dead?) thread but it's relevant to what I am trying to
>> do
>> and it made sense to put it in the same thread.
>>
>> I have the following HashMap:
>>
>> private Map<String, List<Category>> productCategoriesMap;
>>
>> in my includeProperties, productCategoriesMap.* populates the json with
>> every property of the Category bean.  For example:
>>
>>        {
>>        "productCategoriesMap":{"ac80e9b6-29e6-4f00-9410-1a18a9dfd317":[{
>>                "UUID":"4bd497a1-bd1b-417b-8d62-e1273fa5e648",
>>                "name":"Test Sub-Category EDIT",
>>              
>>  "parentCategoryUUID":"65750a38-d596-48d7-a215-56bcb21d8067",
>>              
>>  "providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
>>                },{
>>                "UUID":"65750a38-d596-48d7-a215-56bcb21d8067",
>>                "name":"Category 4",
>>              
>>  "parentCategoryUUID":"98e4b067-5b6b-4777-a28a-443a77209948",
>>              
>>  "providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
>>                }]
>>        }
>>
>> However, I would like to only include UUID and name, as an example.  I
>> have
>> tried:
>>
>> productCategoriesMap.*.name
>> productCategoriesMap.*.*
>> productCategoriesMap[*].name
>> productCategoriesMap.*\.name
>> productCategoriesMap\.*\.name
>>
>> How do I use includeProperties to filter properties of beans within a
>> map?
>> --
>> View this message in context:
>> http://www.nabble.com/JSON-plugin-ignoring-includeProperties-parameter-tp23660860p25240134.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/JSON-plugin-ignoring-includeProperties-parameter-tp23660860p25243032.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by Musachy Barroso <mu...@gmail.com>.
Java regexes are greedy by default if I dont remember wrong, so you
should try something like:

productCategoriesMap[.*?]\.name

or

productCategoriesMap\..*?\.name

musachy

On Tue, Sep 1, 2009 at 6:15 AM, Gadbury<ga...@googlemail.com> wrote:
>
> Hi,
>
> Sorry to jump a (dead?) thread but it's relevant to what I am trying to do
> and it made sense to put it in the same thread.
>
> I have the following HashMap:
>
> private Map<String, List<Category>> productCategoriesMap;
>
> in my includeProperties, productCategoriesMap.* populates the json with
> every property of the Category bean.  For example:
>
>        {
>        "productCategoriesMap":{"ac80e9b6-29e6-4f00-9410-1a18a9dfd317":[{
>                "UUID":"4bd497a1-bd1b-417b-8d62-e1273fa5e648",
>                "name":"Test Sub-Category EDIT",
>                "parentCategoryUUID":"65750a38-d596-48d7-a215-56bcb21d8067",
>                "providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
>                },{
>                "UUID":"65750a38-d596-48d7-a215-56bcb21d8067",
>                "name":"Category 4",
>                "parentCategoryUUID":"98e4b067-5b6b-4777-a28a-443a77209948",
>                "providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
>                }]
>        }
>
> However, I would like to only include UUID and name, as an example.  I have
> tried:
>
> productCategoriesMap.*.name
> productCategoriesMap.*.*
> productCategoriesMap[*].name
> productCategoriesMap.*\.name
> productCategoriesMap\.*\.name
>
> How do I use includeProperties to filter properties of beans within a map?
> --
> View this message in context: http://www.nabble.com/JSON-plugin-ignoring-includeProperties-parameter-tp23660860p25240134.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: JSON plugin ignoring includeProperties parameter

Posted by Gadbury <ga...@googlemail.com>.
Thank you.  I shall check it out.  I didn't know about it.

Thank you, I shall check it out.  However, I would still be interested to
know if and how I can use includeProperties to specify properties of a bean
in a map using the json plugin.

Kind regards,

James



mgainty wrote:
> 
> 
> did you try ParameterFilterInterceptor for filtering stack of your action
> http://struts.apache.org/2.1.2/docs/parameter-filter-interceptor.html
> 
> ?
> Martin Gainty 
> ______________________________________________ 
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>  
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la
> copie de ceci est interdite. Ce message sert à l'information seulement et
> n'aura pas n'importe quel effet légalement obligatoire. Étant donné que
> les email peuvent facilement être sujets à la manipulation, nous ne
> pouvons accepter aucune responsabilité pour le contenu fourni.
> 
> 
> 
> 
>> Date: Tue, 1 Sep 2009 06:15:59 -0700
>> From: gadbury@googlemail.com
>> To: user@struts.apache.org
>> Subject: Re: JSON plugin ignoring includeProperties parameter
>> 
>> 
>> Hi,
>> 
>> Sorry to jump a (dead?) thread but it's relevant to what I am trying to
>> do
>> and it made sense to put it in the same thread.
>> 
>> I have the following HashMap:
>> 
>> private Map<String, List<Category>> productCategoriesMap;
>> 
>> in my includeProperties, productCategoriesMap.* populates the json with
>> every property of the Category bean.  For example:
>> 
>> 	{
>> 	"productCategoriesMap":{"ac80e9b6-29e6-4f00-9410-1a18a9dfd317":[{
>> 		"UUID":"4bd497a1-bd1b-417b-8d62-e1273fa5e648",
>> 		"name":"Test Sub-Category EDIT",
>> 		"parentCategoryUUID":"65750a38-d596-48d7-a215-56bcb21d8067",
>> 		"providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
>> 		},{
>> 		"UUID":"65750a38-d596-48d7-a215-56bcb21d8067",
>> 		"name":"Category 4",
>> 		"parentCategoryUUID":"98e4b067-5b6b-4777-a28a-443a77209948",
>> 		"providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
>> 		}]
>> 	}
>> 
>> However, I would like to only include UUID and name, as an example.  I
>> have
>> tried:
>> 
>> productCategoriesMap.*.name
>> productCategoriesMap.*.*
>> productCategoriesMap[*].name
>> productCategoriesMap.*\.name
>> productCategoriesMap\.*\.name
>> 
>> How do I use includeProperties to filter properties of beans within a
>> map?
>> -- 
>> View this message in context:
>> http://www.nabble.com/JSON-plugin-ignoring-includeProperties-parameter-tp23660860p25240134.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
> 
> _________________________________________________________________
> Windows Live: Keep your friends up to date with what you do online.
> http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_online:082009
> 

-- 
View this message in context: http://www.nabble.com/JSON-plugin-ignoring-includeProperties-parameter-tp23660860p25242034.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by Musachy Barroso <mu...@gmail.com>.
On Tue, Sep 1, 2009 at 6:40 AM, Martin Gainty<mg...@hotmail.com> wrote:
>
> did you try ParameterFilterInterceptor for filtering stack of your action
> http://struts.apache.org/2.1.2/docs/parameter-filter-interceptor.html
>
>

What in the name of Margawse are you talking about? Would you mind
explaining why you think that the parameters interceptor is somehow
related to the output of the JSON result? And link to the
documentation of 2.1.2 which was not even released?

musachy

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: JSON plugin ignoring includeProperties parameter

Posted by Martin Gainty <mg...@hotmail.com>.
did you try ParameterFilterInterceptor for filtering stack of your action
http://struts.apache.org/2.1.2/docs/parameter-filter-interceptor.html

?
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Tue, 1 Sep 2009 06:15:59 -0700
> From: gadbury@googlemail.com
> To: user@struts.apache.org
> Subject: Re: JSON plugin ignoring includeProperties parameter
> 
> 
> Hi,
> 
> Sorry to jump a (dead?) thread but it's relevant to what I am trying to do
> and it made sense to put it in the same thread.
> 
> I have the following HashMap:
> 
> private Map<String, List<Category>> productCategoriesMap;
> 
> in my includeProperties, productCategoriesMap.* populates the json with
> every property of the Category bean.  For example:
> 
> 	{
> 	"productCategoriesMap":{"ac80e9b6-29e6-4f00-9410-1a18a9dfd317":[{
> 		"UUID":"4bd497a1-bd1b-417b-8d62-e1273fa5e648",
> 		"name":"Test Sub-Category EDIT",
> 		"parentCategoryUUID":"65750a38-d596-48d7-a215-56bcb21d8067",
> 		"providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
> 		},{
> 		"UUID":"65750a38-d596-48d7-a215-56bcb21d8067",
> 		"name":"Category 4",
> 		"parentCategoryUUID":"98e4b067-5b6b-4777-a28a-443a77209948",
> 		"providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
> 		}]
> 	}
> 
> However, I would like to only include UUID and name, as an example.  I have
> tried:
> 
> productCategoriesMap.*.name
> productCategoriesMap.*.*
> productCategoriesMap[*].name
> productCategoriesMap.*\.name
> productCategoriesMap\.*\.name
> 
> How do I use includeProperties to filter properties of beans within a map?
> -- 
> View this message in context: http://www.nabble.com/JSON-plugin-ignoring-includeProperties-parameter-tp23660860p25240134.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Windows Live: Keep your friends up to date with what you do online.
http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_online:082009

Re: JSON plugin ignoring includeProperties parameter

Posted by Gadbury <ga...@googlemail.com>.
Hi,

Sorry to jump a (dead?) thread but it's relevant to what I am trying to do
and it made sense to put it in the same thread.

I have the following HashMap:

private Map<String, List<Category>> productCategoriesMap;

in my includeProperties, productCategoriesMap.* populates the json with
every property of the Category bean.  For example:

	{
	"productCategoriesMap":{"ac80e9b6-29e6-4f00-9410-1a18a9dfd317":[{
		"UUID":"4bd497a1-bd1b-417b-8d62-e1273fa5e648",
		"name":"Test Sub-Category EDIT",
		"parentCategoryUUID":"65750a38-d596-48d7-a215-56bcb21d8067",
		"providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
		},{
		"UUID":"65750a38-d596-48d7-a215-56bcb21d8067",
		"name":"Category 4",
		"parentCategoryUUID":"98e4b067-5b6b-4777-a28a-443a77209948",
		"providerRepositoryUUID":"69011624-112a-457b-a222-edd3b543e585"
		}]
	}

However, I would like to only include UUID and name, as an example.  I have
tried:

productCategoriesMap.*.name
productCategoriesMap.*.*
productCategoriesMap[*].name
productCategoriesMap.*\.name
productCategoriesMap\.*\.name

How do I use includeProperties to filter properties of beans within a map?
-- 
View this message in context: http://www.nabble.com/JSON-plugin-ignoring-includeProperties-parameter-tp23660860p25240134.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by Dave Newton <ne...@yahoo.com>.
Martin Gainty wrote:
> Here is the code
> private List<Pattern> includeProperties;
> includeProperties is a List of Regular Expression java.util.regex.Patterns
> javadoc at
> http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html 
> 
> try expressing the String as a regex Pattern e.g.
> <param name="includeProperties">
> [i][t][e][m][s]\p{.}\p{*}\p{\}\p{.}[n][a][m][e]
> </param>

"foo" is a valid regular expression. There's no reason to (and at least 
two reasons *not* to) make every single character part of a character 
set/class, and I can't think of a good reason to match a literal "." 
with anything other than "\.", although I could be wrong on that one.

I'm pretty sure something else is amiss.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: JSON plugin ignoring includeProperties parameter

Posted by Martin Gainty <mg...@hotmail.com>.
Here is the code
private List<Pattern> includeProperties;
includeProperties is a List of Regular Expression java.util.regex.Patterns
javadoc at
http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html 

try expressing the String as a regex Pattern e.g.
<param name="includeProperties">
[i][t][e][m][s]\p{.}\p{*}\p{\}\p{.}[n][a][m][e]
</param>

?
Martin Gainty 
______________________________________________ 
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 Ez az
üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs.  Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Thu, 21 May 2009 15:38:09 -0600
> From: John.C.Cartwright@noaa.gov
> Subject: JSON plugin ignoring includeProperties parameter
> To: user@struts.apache.org
> 
> Hello All,
> 
> I'm trying to use jsonplugin 0.32 w/ struts 2.0.14 and it seems that the
> includeProperties parameter is being ignored.  My configuration looks like:
> 
>          <result type="json">
>             <param name="excludeNullProperties">true</param>
>             <param name="includeProperties">
>             items.*\.name
>             </param>
>          </result>
> 
> Can someone please help me w/ what might be wrong?
> 
> Thanks!
> 
> --john
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Hotmail® has a new way to see what's up with your friends.
http://windowslive.com/Tutorial/Hotmail/WhatsNew?ocid=TXT_TAGLM_WL_HM_Tutorial_WhatsNew1_052009

Re: JSON plugin ignoring includeProperties parameter

Posted by John Cartwright <Jo...@noaa.gov>.
Thank you for your suggestion.  However, using

"features.*\.name"

still does not recognize the property - it is not included in the 
output.  Likewise, removing the annotation does not help either.

--john

Musachy Barroso wrote:
> exclude/include properties have to match the java name of the
> properties, not the name in the output. Try using "features.*\.name"
> as the regular expression.
>
> musachy
>
> On Fri, May 22, 2009 at 10:48 AM, John Cartwright
> <Jo...@noaa.gov> wrote:
>   
>> Thanks for your reply Musachy.
>>
>> I'm using the JSON annotation to modify the output, e.g.
>>
>> @JSON(name="items")
>> public List<Feature> getFeatures() {
>>   return (features);
>> }
>>
>> Yes, I am getting a result. It's just that all the fields are being output
>> rather than just the ones listed in the includeProperties.  As an aside, the
>> "excludeProperties" also seems to be ignored, but the
>> "excludeNullProperties" is respected.
>>
>> Thanks again for your help!
>>
>> --john
>>
>> Musachy Barroso wrote:
>>     
>>> There is a getItems() in your action right? Does anything get generated at
>>> all?
>>>
>>> musachy
>>>
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>     
>
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by Musachy Barroso <mu...@gmail.com>.
exclude/include properties have to match the java name of the
properties, not the name in the output. Try using "features.*\.name"
as the regular expression.

musachy

On Fri, May 22, 2009 at 10:48 AM, John Cartwright
<Jo...@noaa.gov> wrote:
> Thanks for your reply Musachy.
>
> I'm using the JSON annotation to modify the output, e.g.
>
> @JSON(name="items")
> public List<Feature> getFeatures() {
>   return (features);
> }
>
> Yes, I am getting a result. It's just that all the fields are being output
> rather than just the ones listed in the includeProperties.  As an aside, the
> "excludeProperties" also seems to be ignored, but the
> "excludeNullProperties" is respected.
>
> Thanks again for your help!
>
> --john
>
> Musachy Barroso wrote:
>>
>> There is a getItems() in your action right? Does anything get generated at
>> all?
>>
>> musachy
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by John Cartwright <Jo...@noaa.gov>.
Thanks for your reply Musachy.

I'm using the JSON annotation to modify the output, e.g.

@JSON(name="items")
public List<Feature> getFeatures() {
    return (features);
}

Yes, I am getting a result. It's just that all the fields are being 
output rather than just the ones listed in the includeProperties.  As an 
aside, the "excludeProperties" also seems to be ignored, but the 
"excludeNullProperties" is respected.

Thanks again for your help!

--john

Musachy Barroso wrote:
> There is a getItems() in your action right? Does anything get generated at all?
>
> musachy
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by Musachy Barroso <mu...@gmail.com>.
Please don't send private emails following up a thread. This is not a
test case for a bug, this is commented code. I am not saying that
there isn't a bug there, maybe there is.

musachy

On Fri, May 22, 2009 at 9:50 AM, Martin Gainty <mg...@hotmail.com> wrote:
> //rather lengthy testcase for includeProperties
>
> com.googlecode.jsonplugin.JSONResultTest
>   public void testIncludePropertiesWithList() throws Exception {
>         JSONResult result = new JSONResult();
>
> /*public class JSONResult implements Result {
>     private static final long serialVersionUID = 8624350183189931165L;
>     private String defaultEncoding = "ISO-8859-1";
>     private List<Pattern> includeProperties; //you want to initialise this!
> */
>
>         result.setIncludeProperties("^list\\[\\d+\\]\\.booleanField");
>
> /*** @param includedProperties the includeProperties to set
>      */
>     public void setIncludeProperties(String commaDelim) {
>
>         List<String> includePatterns = JSONUtil.asList(commaDelim);
> //splits all Strings using , as delimiter
> /*    public static List<String> asList(String commaDelim) {
>         if ((commaDelim == null) || (commaDelim.trim().length() == 0))
>             return null;
>         List<String> list = new ArrayList<String>();
>         String[] split = commaDelim.split(",");
>         for (int i = 0; i < split.length; i++) {
>             String trimmed = split[i].trim();
>             if (trimmed.length() > 0) {
>                 list.add(trimmed);
>             }
>         }
>         return list;
>     }
> */
>
>         if (includePatterns != null)  //TRUE
>         {
>             this.includeProperties = new
> ArrayList<Pattern>(includePatterns.size());
> //includeProperties now includes ArrayList<Pattern>
>
>             HashMap existingPatterns = new HashMap();
>
>             for (String pattern : includePatterns) {
>                 // Compile a pattern for each *unique* "level" of the object
>                 // hierarchy specified in the regex.
>                 //split according to \ delimiter found
>                 String[] patternPieces = pattern.split("\\\\\\.");
>
>                 String patternExpr = "";
>
> //the individual patternPieces will be referred to as patternPiece
>                 for (String patternPiece : patternPieces)
>                 {
> //patternExpr is null on first go-around (bypass this logic on first
> go-around)
>                     if (patternExpr.length() > 0)
>                     {
>                         patternExpr += "\\.";
>                     }
>                     patternExpr += patternPiece; //patternExpr=patternPiece
>
> // Check for duplicate patterns so that there is no overlap.
> //first go around will always execute logic as !existingPatterns returns
> true
>                     if (!existingPatterns.containsKey(patternExpr))
>                     {
>
> //doesnt make sense..if existingPatterns already contains patternExpr why
> add it again?
> //would'nt you want to leave existingPatterns HashMap alone?
>                         existingPatterns.put(patternExpr, patternExpr);
>
> //Add a pattern that does not have the indexed property matching (ie.
> list\[\d+\] //becomes list).
>
> //look for the end in the piece we have
>                      if (patternPiece.endsWith("\\]"))
>                      {
> //doesnt make sense..you're testing patternPiece.lastIndexOf("\\["))));
> //then why compile patternExpr?
> //why not take the relevant patternPiece and assign it to patternExpr
> //then let the statement  later in the code
> this.includeProperties.add(Pattern.compile(patternExpr)); handle this?
>
> this.includeProperties.add(Pattern.compile(patternExpr.substring(0,
> patternPiece.lastIndexOf("\\["))));
>
> //enable the log so we can see this message
>     if (log.isDebugEnabled())
>                                 log.debug("Adding include property
> expression:  " + patternExpr.substring(0, patternPiece.lastIndexOf("\\[")));
>                         }
>
> //this unconditionally adds the (compiled version of) patternExpr to
> includeProperties
>
> this.includeProperties.add(Pattern.compile(patternExpr));
>
>                         if (log.isDebugEnabled())
>                             log.debug("Adding include property expression:
> " + patternExpr);
>                     }
>                 }
>             }
>         }
>     }
> */
>
> from what i can see there is a bug with JSONResult
> public void setIncludeProperties(String commaDelim) method
>
> ?
> Martin Gainty
> "Good Manners dont cost nothing" - Pink Floyd
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
> de ceci est interdite. Ce message sert à l'information seulement et n'aura
> pas n'importe quel effet légalement obligatoire. Étant donné que les email
> peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
> aucune responsabilité pour le contenu fourni.
>
>
>
>
>> Date: Thu, 21 May 2009 22:42:27 -0400
>> Subject: Re: JSON plugin ignoring includeProperties parameter
>> From: musachy@gmail.com
>> To: user@struts.apache.org
>>
>> There is a getItems() in your action right? Does anything get generated at
>> all?
>>
>> musachy
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
> ________________________________
> Insert movie times and more without leaving Hotmail®. See how.



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSON plugin ignoring includeProperties parameter

Posted by Musachy Barroso <mu...@gmail.com>.
There is a getItems() in your action right? Does anything get generated at all?

musachy

-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org