summaryrefslogtreecommitdiffstats
path: root/schemas/OMNA Schema-based Namespace Registry_fichiers/json.js
blob: 7a8bd4a07f860f3b7e92f9081634abf7185b99ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
Copyright (c) 2005 JSON.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The Software shall be used for Good, not Evil.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

/*
    The global object JSON contains two methods.

    JSON.stringify(value) takes a JavaScript value and produces a JSON text.
    The value must not be cyclical.

    JSON.parse(text) takes a JSON text and produces a JavaScript value. It will
    throw a 'JSONError' exception if there is an error.
*/
if (typeof window.RadControlsNamespace == "undefined")
{
	window.RadControlsNamespace = {};
}

if (
	typeof(window.RadControlsNamespace.JSON) == "undefined" ||
	typeof(window.RadControlsNamespace.JSON.Version) == null ||
	window.RadControlsNamespace.JSON.Version < 1
	)
{	
	
	window.RadControlsNamespace.JSON = {
		
		Version : 1, // Change the version when make changes. Change the value in the IF also
	
	    copyright: '(c)2005 JSON.org',
	    license: 'http://www.crockford.com/JSON/license.html',
	/*
	    Stringify a JavaScript value, producing a JSON text.
	*/
	    stringify: function (v, def) {
	        var a = [];
	        var deep = arguments[2] || {};
	/*
	    Emit a string.
	*/
	        function e(s) {
	            a[a.length] = s;
	        }
	
	/*
	    Convert a value.
	*/
	        function g(x) 
	        {
	            var c, i, l, v;
	
	            switch (typeof x) {
	            case 'object':
	                if (x) {
	                    if (x instanceof Array) {
	                        e('[');
	                        l = a.length;
	                        for (i = 0; i < x.length; i += 1) {
	                            v = x[i];
	                            if (typeof v != 'undefined' &&
	                                    typeof v != 'function') {
	                                if (l < a.length) {
	                                    e(',');
	                                }
	                                g(v);
	                            }
	                        }
	                        e(']');
	                        return '';
	                    } else if (typeof x.valueOf == 'function') 
	                    {
	                        e('{');
	                        l = a.length;
	                        for (i in x) 
	                        {
	                        
	                            v = x[i];
	                            
	                            // Modified to skip default props
	                            if (def && v == def[i])
								{
									continue;
								}
								
								
	                            var type = typeof v;
	                            if (
									type == 'undefined' ||
									type == 'function' 
	                            )
	                            {
									continue;
	                            }
	                            
	                            if (type == "object" && !deep[i])
	                            {
									continue;
	                            }
	                            
	                            
	                            if (l < a.length) 
	                            {
	                                    e(',');
	                            }
	                            g(i);
	                            e(':');
	                            g(v);
	                        }
	                        return e('}');
	                    }
	                }
	                e('null');
	                return '';
	            case 'number':
	                e(isFinite(x) ? +x : 'null');
	                return '';
	            case 'string':
	                l = x.length;
	                e('"');
	                for (i = 0; i < l; i += 1) {
	                    c = x.charAt(i);
	                    if (c >= ' ') {
	                        if (c == '\\' || c == '"') {
	                            e('\\');
	                        }
	                        e(c);
	                    } else {
	                        switch (c) {
	                        case '\b':
	                            e('\\b');
	                            break;
	                        case '\f':
	                            e('\\f');
	                            break;
	                        case '\n':
	                            e('\\n');
	                            break;
	                        case '\r':
	                            e('\\r');
	                            break;
	                        case '\t':
	                            e('\\t');
	                            break;
	                        default:
	                            c = c.charCodeAt();
	                            e('\\u00' + Math.floor(c / 16).toString(16) +
	                                (c % 16).toString(16));
	                        }
	                    }
	                }
	                e('"');
	                return '';
	            case 'boolean':
	                e(String(x));
	                return '';
	            default:
	                e('null');
	                return '';
	            }
	        }
	       
	       g(v, 0);
	        return a.join('');
	    },
	    
	    // Addition
	    stringifyHashTable : function (hash, idMember, initial)
	    {
	        var a = [];
	        if (!initial) initial = [];
	        for (var i = 0; i < hash.length; i ++)
	        {
	            var ser = this.stringify(hash[i], initial[i]);
	            if (ser == '{}') continue;
	            a[a.length] = "\"" + hash[i][idMember] + "\":" + ser;
	        }
	        return "{" + a.join(',') + "}";
	    },
	/*
	    Parse a JSON text, producing a JavaScript value.
	*/
	    parse: function (text) {
	        return (/^([ \t\r\n,:{}\[\]]|"(\\["\\\/bfnrtu]|[^\x00-\x1f"\\]+)*"|-?\d+(\.\d*)?([eE][+-]?\d+)?|true|false|null)+$/.test(text)) &&
	            eval('(' + text + ')');
	    }
	}
}

//BEGIN_ATLAS_NOTIFY
if (typeof(Sys) != "undefined")
{
	if (Sys.Application != null && Sys.Application.notifyScriptLoaded != null)
	{
		Sys.Application.notifyScriptLoaded();
	}
}
//END_ATLAS_NOTIFY
OpenPOWER on IntegriCloud