JSON Comes to Second Life

JSON is pronounced jay-sun. JSON is a text based way of representing data structures. Some think of it as an alternative to XML. It primarily was developed for use in JavaScript programming for transferring data across a network.

I suspect for many of us the arrival of JSON in the Linden Scripting Language (LSL) is a non-event. But, for scripters it is a big deal.

This week the JSON upgrades will be running on the RC channels, all three. The new stuff added to the LSL is:

  • list llJson2List(string json)
    • Converts the top level of the json string to a list.
  • string llList2Json(string type, list values)
  • string llJsonGetValue(string json, list specifiers)
    • Gets the value indicated by specifiers from the json string.
  • string llJsonSetValue(string json, list specifiers, string value)
    • Returns a new json string that is the json given with the value indicated by specifiers set to value
  • string llJsonValueType(string json, list specifiers)
    • Returns the type constant for the value in json indicated by specifiers.
  • Usage guide: Json_usage_in_LSL (added to Wiki 5/14 – today)

You may have noticed in there the mention of ARRAYS. That is a big thing. I’m not sure it is going to give us arrays as we have with other languages. But, it looks to be closer than the strided lists we use.

Provided this Release Candidate makes it past testing this week another set of JSON features will roll into the RC channels next week. No, no word on what those will be.

Kelly Linden is leading the JSON project. Questions on its implementation can be brought to him at the Tuesday Server & Scripting meetings in Denby.

Kelly says we are seeing JSON added to improve the ability to interface LSL with the larger web. The previous maintenance version expanded the content-type support of http-in and http-out which ties in with this JSON addition.