|
|
1.1 misha 1: @main[]
2: $a[^hash::create[]]
3: $b[$.a[$a]]
4: $a.b[$b]
5:
6: $h[
7: $.hash[
1.2 ! moko 8: $.void[$void]
1.1 misha 9: $.bool-true(true)
10: $.bool-false(false)
11: $.int(1)
12: $.double(1/2)
13: $.[a/b]["1"]
14: $.string[value with "quotes"/other things]
15: $.string-ru[русские буквы]
16: $.hash[
17: $.e[ee]
18: ]
19:
20: $._options[
21: $.0[]
22: $.1[$.indent(true)]
23: ]
24: ]
25:
26: $.date[
27: $.value[^date::create(2006;08;18;06;09;00)]
28:
29: $._options[
30: $.0[$.date[unix-timestamp]]
31: $.1[$.date[gmt-string]]
32: $.2[$.date[sql-string]]
33: $.3[$.date[$handler]]
34: ]
35: ]
36:
37: $.table[
38: $.table_nameless_empty[^table::create[nameless]{}]
39: $.table_nameless_1[^table::create[nameless]{v1 v2 v3}]
40: $.table_nameless_2[^table::create[nameless]{v1 v2 v3^#0Av4 v5 v6}]
41: $.table_named_empty[^table::create{c1 c2 c3}]
42: $.table_named_1[^table::create{c1 c2 c3^#0Av1 v2 v3}]
43: $.table_named_2[^table::create{c1 c2 c3^#0Av1 v2 v3^#0Av4 v5 v6}]
44: $.table_named_3[^table::create{c1 c2 c3^#0Av1 v2 v3^#0Av4 v5 v6}]
45:
46: $._options[
47: $.0[$.table[object]]
48: $.1[$.table[object] $.indent(true)]
49: $.2[$.table[array]]
50: $.3[$.table[array] $.indent(true)]
51: ]
52: ]
53:
54: $.my[
55: $.object[^my::create[]]
56:
57: $._options[
58: $.0[$.my[$handler]]
59: ]
60: ]
61:
62: $.file[
63: $.text[^file::create[text;zigi;file-content]]
64: $.binary[^file::load[binary;./256.txt]]
65: $.stated[^file::stat[./256.txt]]
66:
67: $._options[
68: $.0[$.file[text]]
69: $.1[$.file[base64] $.indent(true)]
70: $.2[$.file[$handler]]
71: ]
72: ]
73:
74: $.image[
75: $.value[^image::create(100;100;0)]
76: $._options[
77: $.0[$.skip-unknown(true)]
78: $.1[$.image[$handler]]
79: $.2[$.exception(true)]
80: ]
81: ]
82:
83: $.hash_with_infinite_recursion[
84: $.value[$a]
85:
86: $._options[
87: $.0[$.exception(true)]
88: ]
89: ]
90:
91: ]
92:
93: ^h.table.table_named_3.append{v7 v8 v9 v0}
94:
95: $s[^h.foreach[k;v]{
96: <h3>$k</h3>
97: ^if($v is "hash" && def $v._options){
98: $hOptions[$v._options]
99: $hValue[^hash::create[$v]]
100: ^hValue.delete[_options]
101: ^hOptions.foreach[;hOpt]{^2string[$hValue;$hOpt]}[, ]
102: }{
103: ^2string[$v]
104: }
105: }]
106:
107: ^s.match["([acm]date)":"[^^"]+"][g]{"$match.1":"-value-"}
108:
109:
110: @2string[value;options]
111: $options[^hash::create[$options]]
112: $bShouldBeException($options.exception)
113: ^options.delete[exception]
114: ^try{
115: $result[^json:string[$value;$options]^if($bShouldBeException){. FAILED. EXCEPTION SHOULD BE HERE}]
116: }{
117: $exception.handled(true)
118: $result[Exception^if($bShouldBeException){. That's OK} ($exception.comment)]
119: }
120:
121:
122: @handler[v;p][kk;vv]
123: $result[^switch[$v.CLASS_NAME]{
124: ^case[date]{"new Date(^v.unix-timestamp[])"}
125: ^case[file]{{"file":{"name":"$v.name", "text":"$v.text", "params":"-params-"}}}
126: ^case[image]{"image []"}
127: ^case[DEFAULT]{"$v.CLASS_NAME"}
128: }]
129:
130:
131:
132: @CLASS
133: my
134:
135: @create[]
136: $v[ac/dc]