Because of the way it needlessly does string quoting around object keys.
I'd previously created a JSONLiteral object that protects certain string
from string quotation (such as javascript ) from its little toString()
encoding method sillyness.

I needed this specifically for LinkSubmit so that when I passed in the {}
options structure to tapestry.form.submit() the "this.href" statement was
properly evaluated within the context of the <a> it was embedded in before
being fired off to the tapestry function objects.  Besides that - it's not
legal to have those double quotes in the <a> attributes so it screwed that
up as well.

I have no idea why he decided to do it that way but "whatever". .I also
fixed the exception reporting it does some when importing it initially.  And
now I know why they haven't been able to make JSON structures self
referential in the ecma script spec - otherwise things like "this.href"
would suddenly break.

On 6/14/07, andyhot <[EMAIL PROTECTED]> wrote:

Just wondering, why the signature changes in JSONObject?

[EMAIL PROTECTED] wrote:
> Modified:
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/json/JSONObject.java
> URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/json/JSONObject.java?view=diff&rev=546712&r1=546711&r2=546712
>
==============================================================================
> ---
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/json/JSONObject.java
(original)
> +++
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/json/JSONObject.java
Tue Jun 12 19:35:05 2007
> @@ -25,11 +25,7 @@
>   */
>
>  import java.text.ParseException;
> -import java.util.HashMap;
> -import java.util.Iterator;
> -import java.util.LinkedHashMap;
> -import java.util.Map;
> -import java.util.NoSuchElementException;
> +import java.util.*;
>
>  /**
>   * A JSONObject is an unordered collection of name/value pairs. Its
external
> @@ -505,41 +501,44 @@
>          return o != null ? o.toString() : defaultValue;
>      }
>
> -    public JSONObject put(String key, boolean value)
> +    public JSONObject put(Object key, boolean value)
>      {
>          put(key, Boolean.valueOf(value));
>          return this;
>      }
>
> -    public JSONObject put(String key, double value)
> +    public JSONObject put(Object key, double value)
>      {
>          put(key, new Double(value));
>          return this;
>      }
>
> -    public JSONObject put(String key, long value)
> +    public JSONObject put(Object key, long value)
>      {
>          put(key, new Long(value));
>          return this;
>      }
>
> -    public JSONObject put(String key, int value)
> +    public JSONObject put(Object key, int value)
>      {
>          put(key, new Integer(value));
>          return this;
>      }
>
> -    public JSONObject put(String key, Object value)
> +    public JSONObject put(Object key, Object value)
>      {
> -        if (key == null) { throw new NullPointerException("Null key.");
}
> +        if (key == null)
> +            throw new NullPointerException("Null key.");
> +
>          if (value != null)
>          {
>              this.myHashMap.put(key, value);
>          }
>          else
>          {
> -            remove(key);
> +            remove(key.toString());
>          }
> +
>          return this;
>      }
>
> @@ -663,7 +662,7 @@
>                  sb.append(',');
>              }
>              Object o = keys.next();
> -            sb.append(quote(o.toString()));
> +            sb.append(valueToString(o));
>              sb.append(':');
>              sb.append(valueToString(this.myHashMap.get(o)));
>          }
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Reply via email to