[prev in list] [next in list] [prev in thread] [next in thread]
List: openpkg-cvs
Subject: [CVS] OpenPKG: openpkg-src/json/ json.patch json.spec
From: "Ralf S. Engelschall" <rse () openpkg ! org>
Date: 2006-06-29 6:42:33
Message-ID: 20060629064233.ECCCC1B5BDA () master ! openpkg ! org
[Download RAW message or body]
OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall
Root: /v/openpkg/cvs Email: rse@openpkg.org
Module: openpkg-src Date: 29-Jun-2006 08:42:33
Branch: HEAD Handle: 2006062907423300
Added files:
openpkg-src/json json.patch
Modified files:
openpkg-src/json json.spec
Log:
The JSON JavaScript interface is very elegant but breaks at least
Yahoo User Interface library and all similar code which iterates over
all properties of an object or array. So, provide an explicit
JSON.{encode,decode}() interface which always exist and let
applications just delete the overloaded String/Object/Array methods if
required.
Summary:
Revision Changes Path
1.1 +74 -0 openpkg-src/json/json.patch
1.11 +6 -4 openpkg-src/json/json.spec
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openpkg-src/json/json.patch
============================================================================
$ cvs diff -u -r0 -r1.1 json.patch
--- /dev/null 2006-06-29 08:42:23 +0200
+++ json.patch 2006-06-29 08:42:33 +0200
@@ -0,0 +1,74 @@
+Index: json.js
+--- json.js.orig 2006-06-29 08:25:57 +0200
++++ json.js 2006-06-29 08:36:15 +0200
+@@ -4,22 +4,28 @@
+
+ This file adds these methods to JavaScript:
+
++ JSON.encode(object)
+ object.toJSONString()
+
+ This method produces a JSON text from an object. The
+ object must not contain any cyclical references.
+
++ JSON.encode(array)
+ array.toJSONString()
+
+ This method produces a JSON text from an array. The
+ array must not contain any cyclical references.
+
++ JSON.decode(string)
+ string.parseJSON()
+
+ This method parses a JSON text to produce an object or
+ array. It will return false if there is an error.
+ */
+-(function () {
++
++var JSON = {};
++
++JSON.encode = function (obj) {
+ var m = {
+ '\b': '\\b',
+ '\t': '\\t',
+@@ -99,22 +105,28 @@
+ return '"' + x + '"';
+ }
+ };
++ return s.object(obj);
++};
+
+- Object.prototype.toJSONString = function () {
+- return s.object(this);
+- };
+-
+- Array.prototype.toJSONString = function () {
+- return s.array(this);
+- };
+-})();
+-
+-String.prototype.parseJSON = function () {
++JSON.decode = function (str) {
+ try {
+ return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
+- this.replace(/"(\\.|[^"\\])*"/g, ''))) &&
+- eval('(' + this + ')');
++ str.replace(/"(\\.|[^"\\])*"/g, ''))) &&
++ eval('(' + str + ')');
+ } catch (e) {
+ return false;
+ }
+ };
++
++String.prototype.parseJSON = function () {
++ return JSON.decode(this);
++};
++
++Object.prototype.toJSONString = function () {
++ return JSON.encode(this);
++};
++
++Array.prototype.toJSONString = function () {
++ return JSON.encode(this);
++};
++
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/json/json.spec
============================================================================
$ cvs diff -u -r1.10 -r1.11 json.spec
--- openpkg-src/json/json.spec 22 Jun 2006 13:29:17 -0000 1.10
+++ openpkg-src/json/json.spec 29 Jun 2006 06:42:33 -0000 1.11
@@ -39,8 +39,8 @@
Class: EVAL
Group: Language
License: Open Source
-Version: 20060622
-Release: 20060622
+Version: 20060629
+Release: 20060629
# list of sources
Source0: http://oss.metaparadigm.com/json-c/json-c-%{V_api_c}.tar.gz
@@ -48,6 +48,7 @@
Source2: http://www.cpan.org/authors/id/M/MA/MAKAMAKA/JSON-PC-%{V_api_pl2}.tar.gz
Source3: ftp://ftp.openpkg.org/sources/CPY/VERSIONED/json/json-%{V_api_js}.js
Source4: http://www.json.org/draft-crockford-jsonorg-json-%{V_draft}.txt
+Patch0: json.patch
# build information
Prefix: %{l_prefix}
@@ -93,6 +94,8 @@
%setup -q -c
%setup -q -T -D -a 1
%setup -q -T -D -a 2
+ cp %{SOURCE json-%{V_api_js}.js} json.js
+ %patch -p0
%build
( cd json-c-%{V_api_c}
@@ -115,8 +118,7 @@
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/share/json
%{l_shtool} install -c -m 644 \
- %{SOURCE json-%{V_api_js}.js} \
- $RPM_BUILD_ROOT%{l_prefix}/share/json/json.js
+ json.js $RPM_BUILD_ROOT%{l_prefix}/share/json/
%{l_shtool} install -c -m 644 \
%{SOURCE draft-crockford-jsonorg-json-%{V_draft}.txt} \
$RPM_BUILD_ROOT%{l_prefix}/share/json/json.txt
@@ .
______________________________________________________________________
The OpenPKG Project www.openpkg.org
CVS Repository Commit List openpkg-cvs@openpkg.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic