#1285 oBIX example?

msl Mon 1 Nov 2010

Reading the oBIX spec on the train (wondered what that pod was) and wondering whether there are any examples floating around of obixMod et al?

brian Mon 1 Nov 2010

The spec obviously has lots of examples, but oBIX is just another way to serialize object trees. Like JSON is is better for programming data structures because it doesn't treat everything like a string: you have ints, bools, lists, etc. But it goes beyond JSON to include date/time types, typing information, and REST based hyperlink references.

Here is a simple example:

// Fantom serialization
Person
{
  fullName = "John Smith"
  bday     = Date("1960-05-01")
  married  = true
}

// oBIX
<obj is="Person">
   <str  name="fullName" val="John Smith"/>
   <date name="bday"     val="1960-05-01"/>
   <bool name="married"  val="true"/>
</obj>

Perhaps the coolest aspect of oBIX is that "schemas" are defined using prototype inheritance which works great for XML. For example the schema (or in oBIX the contract) for Person might be:

<obj href="Person">
   <str  name="fullName"/>
   <date name="bday"/>
   <bool name="married"/>
</obj>

Login or Signup to reply.