comparison modules/json.tp @ 329:eef8a5cea812

Use a smarter algorithm for calculating module init order and break some circular module dependencies in the standard library
author Michael Pavone <pavone@retrodev.com>
date Sat, 28 Mar 2015 13:26:03 -0700
parents ddf38b66b2e2
children 3d36d69aab7f
comparison
equal deleted inserted replaced
328:c1fad3d93861 329:eef8a5cea812
163 decode <- :text { 163 decode <- :text {
164 (_decode: text at: 0) value 164 (_decode: text at: 0) value
165 } 165 }
166 166
167 encode <- :value { 167 encode <- :value {
168 if: (object does: value understand?: "jsonEncode") { 168 jsonEncoder encode: value
169 value jsonEncode
170 } else: {
171 toEncode <- #[]
172 if: (object does: value understand?: "serializeFields") {
173 toEncode <- value serializeFields
174 } else: {
175 toEncode <- object propertiesOf: value
176 }
177 parts <- #[]
178 foreach: toEncode :idx field {
179 fieldVal <- object sendMessage: field to: value
180 parts append: (field jsonEncode) . ":" . (encode: fieldVal)
181 }
182 "{" . (parts join: ",") . "}"
183 }
184 } 169 }
185 170
186 main <- { 171 main <- {
187 o <- #{ 172 o <- #{
188 foo <- "bar" 173 foo <- "bar"