|
|
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)]
1.3 moko 51: $.4[$.table[compact]]
52: $.5[$.table[compact] $.indent(true)]
1.1 misha 53: ]
54: ]
55:
56: $.my[
57: $.object[^my::create[]]
58:
59: $._options[
60: $.0[$.my[$handler]]
61: ]
62: ]
63:
64: $.file[
65: $.text[^file::create[text;zigi;file-content]]
66: $.binary[^file::load[binary;./256.txt]]
67: $.stated[^file::stat[./256.txt]]
68:
69: $._options[
70: $.0[$.file[text]]
71: $.1[$.file[base64] $.indent(true)]
72: $.2[$.file[$handler]]
73: ]
74: ]
75:
76: $.image[
77: $.value[^image::create(100;100;0)]
78: $._options[
79: $.0[$.skip-unknown(true)]
80: $.1[$.image[$handler]]
81: $.2[$.exception(true)]
82: ]
83: ]
84:
85: $.hash_with_infinite_recursion[
86: $.value[$a]
87:
88: $._options[
89: $.0[$.exception(true)]
90: ]
91: ]
92:
1.4 ! misha 93: $.xdoc[
! 94: $.value[^xdoc::create{<?xml version="1.0"?><r><t z="1"/></r>}]
! 95: $._options[
! 96: $.0[]
! 97: $.1[$.xdoc[
! 98: $.omit-xml-declaration[yes]
! 99: $.indent[yes]
! 100: ]]
! 101: ]
! 102: ]
1.1 misha 103: ]
104:
105: ^h.table.table_named_3.append{v7 v8 v9 v0}
1.3 moko 106: ^h.table.table_named_3.append{vA"}
107: ^h.table.table_named_3.append{vB\}
1.1 misha 108:
109: $s[^h.foreach[k;v]{
110: <h3>$k</h3>
111: ^if($v is "hash" && def $v._options){
112: $hOptions[$v._options]
113: $hValue[^hash::create[$v]]
114: ^hValue.delete[_options]
115: ^hOptions.foreach[;hOpt]{^2string[$hValue;$hOpt]}[, ]
116: }{
117: ^2string[$v]
118: }
119: }]
120:
121: ^s.match["([acm]date)":"[^^"]+"][g]{"$match.1":"-value-"}
122:
123:
124: @2string[value;options]
125: $options[^hash::create[$options]]
126: $bShouldBeException($options.exception)
127: ^options.delete[exception]
128: ^try{
129: $result[^json:string[$value;$options]^if($bShouldBeException){. FAILED. EXCEPTION SHOULD BE HERE}]
130: }{
131: $exception.handled(true)
132: $result[Exception^if($bShouldBeException){. That's OK} ($exception.comment)]
133: }
134:
135:
1.3 moko 136: @handler[k;v;p][kk;vv]
1.1 misha 137: $result[^switch[$v.CLASS_NAME]{
138: ^case[date]{"new Date(^v.unix-timestamp[])"}
139: ^case[file]{{"file":{"name":"$v.name", "text":"$v.text", "params":"-params-"}}}
140: ^case[image]{"image []"}
1.3 moko 141: ^case[DEFAULT]{"$v.CLASS_NAME at key $k, with ^p._count[] option"}
1.1 misha 142: }]
143:
144:
145:
146: @CLASS
147: my
148:
149: @create[]
150: $v[ac/dc]