Skip to content

Instantly share code, notes, and snippets.

@vito
Created October 15, 2010 02:25
Show Gist options
  • Save vito/627489 to your computer and use it in GitHub Desktop.
Save vito/627489 to your computer and use it in GitHub Desktop.
quick-and-dirty JSON
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
{ "bar": "two", "baz": 3.0, "foo": 1, "nested": { "foo": [1, "two", 3.0], "something-else": "i duno lol" } }
@relrod
Copy link

relrod commented Oct 16, 2010

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment