adding JSON support to exyus

2008-02-01 @ 00:47#

i finally got JSON support added to the exyus engine this week. it's a small start - just added the ability to include application/json content-types for GET,HEAD requests. actually, all that takes is adding a new XSLT document that outputs the JSON. that's what i like about this engine - adding support for a new content-type is not all that complex.

here's an example of the text/xml representation followed by the application/json version:

<?xml version="1.0" encoding="utf-8"?>
<tasks xml:base="http://localhost/xcs/tasklist/">
  <task href="x8ca2f68ed5464b2" seq="1">
    <name>Read TaskList Tutorial</name>
    <is-completed>1</is-completed>
  </task>
  <task href="x8ca2f68f058de9a" seq="2">
    <name>Download Exyus</name>
    <is-completed>0</is-completed>
  </task>
  <task href="x8ca2f68f623d546" seq="3">
    <name>Install and run examples</name>
    <is-completed>0</is-completed>
  </task>
  <task href="x8ca2f690144ef64" seq="4">
    <name>Use Exyus to build my own cool app</name>
    <is-completed>0</is-completed>
  </task>
</tasks>

{"tasks" :
  { "xml:base":"http://localhost/xcs/tasklist/",
  "task" : 
   [
    {"id" : "x8ca2f68ed5464b2", "seq" : "1", "name" : "Read TaskList Tutorial", "is-completed" : "1"}
    ,
    {"id" : "x8ca2f68f058de9a", "seq" : "2", "name" : "Download Exyus", "is-completed" : "0"}
    ,
    {"id" : "x8ca2f68f623d546", "seq" : "3", "name" : "Install and run examples", "is-completed" : "0"}
    ,
    {"id" : "x8ca2f690144ef64", "seq" : "4", "name" : "Use Exyus to build my own cool app", "is-completed" : "0"}
    ]
  }
}

i still need to work up support for using application/json for PUT,POST. i should have that working by next week.

code