Hi Jakub,
Sorry for the lack of response on this.
I have checked the names. The add("user") bit was just an example from me.
The code is correct but I might be slightly confused as to what to use here?
Should it be add("user") or add("users") ?
Jakub Podlesak wrote:
> 
> 
> Hi Sarat,
> 
> please see inline...
> 
> On Sun, Dec 21, 2008 at 02:17:50PM -0800, sarat.pediredla wrote:
>> 
>> Hi,
>> 
>> I know that in Jersey 1.0, to enable JSON elements to be forced to be
>> displayed as arrays, I can use the following,
>> 
>> props.put(JSONJAXBContext.JSON_ARRAYS, new
>> HashSet<String>(1){{add("user");}}); 
>> 
>> This might seem a newbie question but what do I do when I want multiple
>> beans added to the JSON_ARRAYS list? Is the following code right? It
>> definitely does not work as the JSON returned does not treat single
>> elements
>> as arrays.
> 
> Could you please send out a simple test case.
> Your code for setting the JSON_ARRAYS property looks fine and the thing
> should work.
> There is even a junit test
> [JsonXmlStreamReaderWriterTest.testTwoListsWrapper]
> for your case.
> 
> Could you maybe double-check you added the right names?
> I can see add("user") in your first example, and then add("users")
> in the second. Are the names correct?
> 
> ~Jakub
> 
>> 
>> public class JsonContextResolver implements ContextResolver<JAXBContext>
>> {
>> 
>>    private JAXBContext context;
>>    private Class[] types = {
>>            User.class,
>>            Role.class,
>>            Group.class
>>    };
>> 
>>    public JsonContextResolver() throws Exception {
>>        Map props = new HashMap<String, Object>();
>>        props.put(JSONJAXBContext.JSON_NOTATION,
>> JSONJAXBContext.JSONNotation.MAPPED);
>>        props.put(JSONJAXBContext.JSON_ROOT_UNWRAPPING, Boolean.TRUE);
>>        props.put(JSONJAXBContext.JSON_ARRAYS, new
>> HashSet<String>(types.length){{
>>            add("users");
>>            add("roles");
>>            add("groups");
>>        }});
>>        this.context = new JSONJAXBContext(types, props);
>>    }
>> 
>>    public JAXBContext getContext(Class<?> objectType) {
>>        for(Class<?> x : types){
>>            if(x.equals(objectType)){
>>                return context;
>>            }
>>        }
>>        return null;
>>    }
>> -- 
>> View this message in context:
>> http://n2.nabble.com/JSON-Arrays-tp1687952p1687952.html
>> Sent from the Jersey mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
> 
> 
> 
-- 
View this message in context: http://n2.nabble.com/JSON-Arrays-tp1687952p2200121.html
Sent from the Jersey mailing list archive at Nabble.com.