Apachec json question: extra [ ] in toString method?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Apachec json question: extra [ ] in toString method?

Tim Chuong
I am new to this.  Sorry for the newbie question.

I have this simple class.

import org.apache.wink.json4j.JSONObject;
public class JsonExpl {
    public static void main(String[] args) throws Exception {
       JSONObject obj1 = new JSONObject();
       String [] ar = {"patric", "ireland"};      
       obj1.append("david", "wales");
       obj1.append("andrew", "scotland");
       obj1.append("array", ar);

It prints out:

Shouldn't this be:
{"andrew":"scotland","david":"wales","array":["patric","ireland"]}  ???

In other words, does toString() add extra [ ] around all values?  The problem is some other application takes this as input will interpret the [ ] as an array.

Thank you for help.