There are two new methods added to class “Object”:
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).
Peter, this is looking superb!!!
Comment by Andy Burnett — April 3, 2007 @ 3:03 pm
Thank you Andy.
Comment by pfisk — April 3, 2007 @ 4:01 pm
[...] 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