<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Objective-J/json2.js</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -671,7 +671,7 @@ var CPStringRegexSpecialCharacters = [
 */
 + (CPString)JSONFromObject:(JSObject)anObject
 {
-    return CPJSObjectCreateJSON(anObject);
+    return JSON.stringify(anObject);
 }
 
 /*!
@@ -679,7 +679,7 @@ var CPStringRegexSpecialCharacters = [
 */
 - (JSObject)objectFromJSON
 {
-    return CPJSObjectCreateWithJSON(self);
+    return JSON.parse(self);
 }
 
 @end</diff>
      <filename>Foundation/CPString.j</filename>
    </modified>
    <modified>
      <diff>@@ -99,126 +99,14 @@ var CPValueValueKey = @&quot;CPValueValueKey&quot;;
 
 @end
 
-var _JSONCharacterEncodings   = {};
-
-_JSONCharacterEncodings['\b']    = &quot;\\b&quot;;
-_JSONCharacterEncodings['\t']    = &quot;\\t&quot;;
-_JSONCharacterEncodings['\n']    = &quot;\\n&quot;;
-_JSONCharacterEncodings['\f']    = &quot;\\f&quot;;
-_JSONCharacterEncodings['\r']    = &quot;\\r&quot;;
-_JSONCharacterEncodings['&quot;']     = &quot;\\\&quot;&quot;;
-_JSONCharacterEncodings['\\']    = &quot;\\\\&quot;;
-
-// FIXME: Workaround for https://trac.280north.com/ticket/16
-var _JSONEncodedCharacters  = new RegExp(&quot;[\\\&quot;\\\\\\x00-\\x1f\\x7f-\\x9f]&quot;, 'g');
-
 function CPJSObjectCreateJSON(aJSObject)
 {
-    // typeof new Number() and new String() gives you &quot;object&quot;, 
-    // so valueof in those cases.
-    var type = typeof aJSObject,
-        valueOf = aJSObject ? aJSObject.valueOf() : null,
-        typeValueOf = typeof valueOf;
-    
-    if (type != typeValueOf)
-    {
-        type = typeValueOf;
-        aJSObject = valueOf;
-    }
-    
-    switch (type)
-    {
-        case &quot;string&quot;:  // If the string contains no control characters, no quote characters, and no
-                        // backslash characters, then we can safely slap some quotes around it.
-                        // Otherwise we must also replace the offending characters with safe sequences.
-
-                        if (!_JSONEncodedCharacters.test(aJSObject))
-                            return '&quot;' + aJSObject + '&quot;';
-                        
-                        return '&quot;' + aJSObject.replace(_JSONEncodedCharacters, _CPJSObjectEncodeCharacter) + '&quot;';
-            
-
-        case &quot;number&quot;:  // JSON numbers must be finite. Encode non-finite numbers as null.
-                        return isFinite(aJSObject) ? String(aJSObject) : &quot;null&quot;;
-
-        case &quot;boolean&quot;: 
-        case &quot;null&quot;:    return String(aJSObject);
-
-        case &quot;object&quot;:  // Due to a specification blunder in ECMAScript,
-                        // typeof null is 'object', so watch out for that case.
-                        
-                        if (!aJSObject)
-                            return &quot;null&quot;;
-    
-                        // If the object has a toJSON method, call it, and stringify the result.
-    
-                        if (typeof aJSObject.toJSON === &quot;function&quot;)
-                            return CPJSObjectCreateJSON(aJSObject.toJSON());
-                        
-                        var array = [];
-                        
-                        // If the object is an array. Stringify every element. Use null as a placeholder
-                        // for non-JSON values.
-                        if (aJSObject.slice)
-                        {
-                            var index = 0,
-                                count = aJSObject.length;
-                                
-                            for (; index &lt; count; ++index)
-                                array.push(CPJSObjectCreateJSON(aJSObject[index]) || &quot;null&quot;);
-                                                
-                            // Join all of the elements together and wrap them in brackets.
-                            return '[' + array.join(',') + ']';
-                        }
-                        
-                        
-                        // Otherwise, iterate through all of the keys in the object.
-                        var key = NULL;
-                        
-                        for (key in aJSObject)
-                        {
-                            if (!(typeof key === &quot;string&quot;))
-                                continue;
-                            
-                            var value = CPJSObjectCreateJSON(aJSObject[key]);
-                            
-                            if (value)
-                                array.push(CPJSObjectCreateJSON(key) + ':' + value);
-                        }
-                        
-                        // Join all of the member texts together and wrap them in braces.
-                        return '{' + array.join(',') + '}';
-    }       
-}
-
-var _CPJSObjectEncodeCharacter = function(aCharacter)
-{
-    var encoding = _JSONCharacterEncodings[aCharacter];
-                            
-    if (encoding)
-        return encoding;
-    
-    encoding = aCharacter.charCodeAt(0);
-                            
-    return '\\u00' + FLOOR(encoding / 16).toString(16) + (encoding % 16).toString(16);
+    CPLog.warn(&quot;CPJSObjectCreateJSON deprecated, use JSON.stringify() or CPString's objectFromJSON&quot;);
+    return JSON.stringify(aJSObject);
 }
 
-var _JSONBackslashCharacters    = new RegExp(&quot;\\\\.&quot;, 'g'),
-    _JSONSimpleValueTokens      = new RegExp(&quot;\&quot;[^\&quot;\\\\\\n\\r]*\&quot;|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?&quot;, 'g'),
-    _JSONValidOpenBrackets      = new RegExp(&quot;(?:^|:|,)(?:\\s*\\[)+&quot;, 'g'),
-    _JSONValidExpression        = new RegExp(&quot;^[\\],:{}\\s]*$&quot;);
-
 function CPJSObjectCreateWithJSON(aString)
 {
-    if (_JSONValidExpression.test(aString.replace(_JSONBackslashCharacters, '@').replace(_JSONSimpleValueTokens, ']').replace(_JSONValidOpenBrackets, '')))
-        return eval('(' + aString + ')');
-
-    return nil;
+    CPLog.warn(&quot;CPJSObjectCreateWithJSON deprecated, use JSON.parse() or CPString's JSONFromObject&quot;);
+    return JSON.parse(aString);
 }
-
-/*
-var _JSONBackslashCharacters    = /\\./g,
-    _JSONSimpleValueTokens      = /&quot;[^&quot;\\\n\r]*&quot;|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
-    _JSONValidOpenBrackets      = /(?:^|:|,)(?:\s*\[)+/g,
-    _JSONValidExpression        = /^[\],:{}\s]*$/;
-*/</diff>
      <filename>Foundation/CPValue.j</filename>
    </modified>
    <modified>
      <diff>@@ -19,6 +19,7 @@ task :Products =&gt; [$BROWSER_FILE, $RHINO_FILE, $LICENSE_PRODUCT]
 
 Files = [   'constants.js', 
             'utilities.js', 
+            'json2.js',
             'runtime.js', 
             'dictionary.js', 
             'plist.js', </diff>
      <filename>Objective-J/Rakefile</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1224ca9493c78ecf3b4d6abdff9bfe3e9f900a8b</id>
    </parent>
  </parents>
  <author>
    <name>Tom Robinson</name>
    <email>tom@280north.com</email>
  </author>
  <url>http://github.com/280north/cappuccino/commit/cfda93d1e3a0c5279edffa6cf74743d14c9151be</url>
  <id>cfda93d1e3a0c5279edffa6cf74743d14c9151be</id>
  <committed-date>2009-06-02T15:02:25-07:00</committed-date>
  <authored-date>2009-06-02T15:02:25-07:00</authored-date>
  <message>Update JSON support to json2.js, added in Objective-J. Deprecate CPJSObjectCreateJSON and CPJSObjectCreateWithJSON.</message>
  <tree>caf9b50a73aba4972dec4ac4381140e202a2913b</tree>
  <committer>
    <name>Tom Robinson</name>
    <email>tom@280north.com</email>
  </committer>
</commit>
