comparison modules/list.tp @ 271:bb4723fec05e

Support for encoding objects, dictionaries, lists and arrays to JSON in json module
author Michael Pavone <pavone@retrodev.com>
date Sat, 19 Jul 2014 19:59:51 -0700
parents f3d5068cbd43
children ea94b1e43c97 ed908b7fcec6
comparison
equal deleted inserted replaced
270:b74956a2196f 271:bb4723fec05e
12 reverse <- { self } 12 reverse <- { self }
13 join <- { "" } 13 join <- { "" }
14 contains? <- :val { false } 14 contains? <- :val { false }
15 string <- { "[]" } 15 string <- { "[]" }
16 print <- { print: string } 16 print <- { print: string }
17 jsonEncode <- { "[]" }
17 } 18 }
18 #{ 19 #{
19 empty <- { _empty } 20 empty <- { _empty }
20 node:withTail <- :_val :_tail { 21 node:withTail <- :_val :_tail {
21 #{ 22 #{
81 foreach: :_ el { 82 foreach: :_ el {
82 print: " " . (string: el) . "\n" 83 print: " " . (string: el) . "\n"
83 } 84 }
84 print: "]" 85 print: "]"
85 } 86 }
87
88 jsonEncode <- {
89 parts <- map: :el { json encode: el }
90 "[" . (parts join: ",") . "]"
91 }
86 } 92 }
87 } 93 }
88 } 94 }
89 } 95 }