21st Century Smalltalk

April 2, 2007

JSON Serialization in Vst/Flash

Filed under: Vista Smalltalk — pfisk @ 6:33 pm

There are two new methods added to class “Object”:

  • toJson – encodes the object as a JSON string
  • toJson64 – encodes the object as a JSON BASE64 string

And two corresponding new methods in the class “String”:

  • fromJson – converts a JSON string back to an object
  • fromJson64 – converts a JSON BASE64 string back to an object

 As an example in Smalltalk:

#(1 2 3 'this' 'is' 'a' 'json' 'test' 4 5 6 7) toJson64

produces the string

'WzEsMiwzLCJ0aGlzIiwiaXMiLCJhIiwianNvbiIsInRlc3QiLDQsNSw2LDdd'

and

'WzEsMiwzLCJ0aGlzIiwiaXMiLCJhIiwianNvbiIsInRlc3QiLDQsNSw2LDdd' fromJson64

produces the original object

#(1 2 3 'this' 'is' 'a' 'json' 'test' 4 5 6 7)

These serialization methods have been added in preparation for:

  • exchanging objects between a Vst/Flash session and server programs (eg PHP)
  • exchanging objects between Vst/Flash sessions through P2P (eg Jabber/XMPP)

Hopefully, the beta for the XIFF IM project will soon be available.

If XIFF works as I expect, Vst/Flash should be able to exchange objects in real time between browser or Apollo sessions through any public Jabber server (and probably Google Talk as well).

3 Comments »

  1. Peter, this is looking superb!!!

    Comment by Andy Burnett — April 3, 2007 @ 3:03 pm

  2. Thank you Andy.

    Comment by pfisk — April 3, 2007 @ 4:01 pm

  3. [...] JSON Serialization in Vst/Flash « 21st Century Smalltalk “If XIFF works as I expect, Vst/Flash should be able to exchange objects in real time between browser or Apollo sessions through any public Jabber server (and probably Google Talk as well).” (tags: Apollo Adobe Smalltalk) [...]

    Pingback by James Governor’s Monkchips » links for 2007-04-03 — April 3, 2007 @ 11:32 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.