JSONSerializer doesn't work with arrays - it only works with Lists (since lists 
can be dynamically sized, whereas arrays cannot). Try changing String[] to 
ArrayList<String> and it should work fine.

On Apr 18, 2011, at 1:28 PM, Duto wrote:

> I have a problem with JSON and Array of String :
> 
> public class Test {
>    private String[] arrayString = new String[] {"row1", "row2", "row3"};
> 
> 
>    public String[] getArrayString() {
>        return arrayString;
>    }
> 
>    public void setArrayString(String[] arrayString) {
>        this.arrayString = arrayString;
>    }
> 
>    public static void main(String[] args) {
>        System.out.println(JSON.containsKey(new BeanAdapter(new Test()),
> "arrayString[0]"));
>    }
> }
> 
> I get this error : 
> 
> Exception in thread "main" java.lang.IllegalArgumentException: Property "0"
> not found.
>       at org.apache.pivot.json.JSON.containsKey(JSON.java:244)
>       at Test.main(Poub.java:24)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
> 
> 
> If someone can help me.
> 
> Best regards 
> 
> Duto
> 
> 
> --
> View this message in context: 
> http://apache-pivot-users.399431.n3.nabble.com/json-and-array-tp2835305p2835305.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Reply via email to