21st Century Smalltalk

June 21, 2007

JSON Serialization in Silverlight

Filed under: Games, Silverlight — pfisk @ 9:18 pm

smalltalk25

Above is Smalltalk/DLR running in a browser with Silverlight 1.1.

Two more buttons have been added to the Designer menu:

  • Save - serializes the designer contents to a JSON formatted string, stores the string internally, and writes it to the Transcript window.
  • Load – recreates the designer contents from an internally stored JSON string.

You can test this by using the Designer to create a drawing and then clicking the “Save” button. Delete the drawing (or open another Designer window) and click “Load” to restore the drawing.

For the moment, this is set up as an internal test. Tomorrow, I will add the server components as well and, by next week, there should be a test library of pre-built diagrams that can be loaded from the main site at http://vistascript.net.

Silverlight contains a XamlReader class but not XamlWriter; so, while you can read Xaml (produced by Expression or Visual Studio), you cannot create Xaml.

However, Silverlight does have a good JSON serializer (JavaScriptSerializer) which can both serialize and deserialize to JSON format. I have built JSON support into all Smalltalk/DLR graphical objects.

An advantage of using JSON format is that other data can easily be stored along with the graphical object. For example, a game avatar could store lists of powers, friends, or strategies.

Silverlight is going to be an excellent gaming platform.

1 Comment »

  1. شات سعودي

    Comment by شات — November 7, 2009 @ 11:16 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.