annotate samples/json.tp @ 253:697c2c562af2

Fix infinite loop in hash dict
author Michael Pavone <pavone@retrodev.com>
date Sat, 31 May 2014 21:27:03 -0700
parents 6e579a75a0a9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
154
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #{
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 main <- {
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 arr <- json decode: "[\"foo\", \"bar\", 13245, \"baz\" ]"
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 foreach: arr :idx val {
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 print: (string: idx) . ": " . (string: val) . "\n"
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 }
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 obj <- json decode: "{\"foo\": \"bar\", \"baz\": \"qux\", \"meaningOfLife\": 42 }"
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 foreach: obj :idx val {
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 print: (string: idx) . ": " . (string: val) . "\n"
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 }
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 }
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 }