Web 2.0 to OpenSim made easy (JSON support added)

I’ve been tracking the progress of the OpenSim project for quite some time now and gradually delving deeper into the midst of this little open-source wonder.

For those of you who haven’t come across OpenSim, or have heard of it but haven’t investigated in too much detail; OpenSim is a Virtual Worlds platform built from the ground up which uses the Second Life protocol. Initially OpenSim has set out to emulate the current function of the Second Life servers. This means that you use the Second Life client to log onto an OpenSim server.

OpenSim has been built in a modular fashion, meaning that particular modules can be swapped in and out depending on the purpose of the Virtual World you wish to run. At the moment the modules are limited to things like… support for different databases, physics engines, scripting engines etc.

In the future I expect to see a whole raft of new modules ranging from the important but slightly mundane, authentication e.g. LDAP, OpenID etc. to plugins allowing different client types e.g. Flash, Unity etc. and modules for payment systems etc.

At the moment OpenSim is still in alpha, with stability a high priority. Already though it is becoming well fleshed out with building, avatar customization the ability to connect multiple sims (islands) together and a healthy base of scripting available enabling the majority of existing LSL scripts to run and also allowing c# and other languages to be used.

In addition to the LSL scripting ported from Second Life there are extra API calls that can be made that enable function such as loading images from the web directly onto objects in world. There is also a scripting API that lets you format text and images on objects.

As I have become more involved in OpenSim and got to learn how it works a bit more I thought it time to start contributing something towards the codebase. A long time ago in Second Life I created a translation device that listened to your conversation and sent the text out to Google to be translated, it then read out the translation in world.

There are many other services in Second Life that use this pattern of utilizing services around the Web. The LSL scripting language however is not good at handling the formats that most Web 2.0 APIs and services speak. In fact may SL gadgets and devices rely on custom web server scripts to speak to the outside service and cut down the data drastically before its passed back into SL where the gadget uses it. This is a major pain in the ass as any SL gadget creator will tell you.

One of the most common formats used by Web 2.0 service APIs (Google,Flickr, Yahoo etc.) is called JSON (or javascript object notation). JSON is a simple way of describing objects, however it can come in many shapes and sizes making it almost possible to consume directly in SL or OpenSim.

For that reason my first contribution to the OpenSim project is to implement a scripting function called osParseJSON, which should hopefully open the flood gates for people who want to make the most of the Web 2.0 services they use every day and get that data into OpenSim.

For now I’ve written a simple example, that uses Googles translation API. The example lets you translate between 23 different languages.