Created
October 15, 2010 02:25
-
-
Save vito/627489 to your computer and use it in GitHub Desktop.
quick-and-dirty JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JSON = Object clone | |
(s: String) as: JSON := s show | |
(d: Double) as: JSON := d show | |
(i: Integer) as: JSON := i show | |
(l: List) as: (j: JSON) := | |
"[" .. l (map: @(as: j)) (join: ", ") .. "]" | |
(b: Block) as: (j: JSON) := | |
Object clone (do: b) (as: j) | |
o as: (j: JSON) := | |
{ ms = o methods singles (map: @head) | |
pair = | |
{ m | | |
m pattern name show .. ": " .. m value (as: j) | |
} | |
"{ " .. ms (map: pair) (join: ", ") .. " }" | |
} call | |
obj = | |
{ foo = 1 | |
bar = "two" | |
baz = 3.0 | |
nested = | |
{ foo = [1, "two", 3.0] | |
something-else = "i duno lol" | |
} | |
} | |
obj (as: JSON) print |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "bar": "two", "baz": 3.0, "foo": 1, "nested": { "foo": [1, "two", 3.0], "something-else": "i duno lol" } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This language almost seems sorta cool :P
Seems very much like Io, with some added haskellisms.
I'm almost interested in it.... might take a look at it at some point in the near future.