Advice on Custom Serialization

Jun 3, 2010 at 9:08 PM
Edited Jun 3, 2010 at 9:09 PM

I'm trying to create serializable classes for configuring FlowPlayer from .NET. Here is what the plugin section looks like when serialized:

 

"plugins": {
    "content": {
      "displayProperties": {
        "opacity": 1.0,
        "bottom": "25",
        "width": "80pct",
        "height": "40"
      },
      "styleProperties": {
        "border": "0",
        "borderRadius": "4"
      },
      "url": "http://...flowplayer.content.swf"
    },
    "captions": {
      "url": "http://...flowplayer.captions.swf"
    }
  }

 

The problem is that I want displayProperties and styleProperties to be managed as separate objects in .NET but when serialized, be embedded in whatever object without the object name and having the properties look like they belong to the main object. So instead of the above, I want the serialization to give me this:

 

"plugins": {
    "content": {
      "opacity": 1.0,
      "bottom": "25",
      "width": "80pct",
      "height": "40"
      "border": "0",
      "borderRadius": "4"
      "url": "http://...flowplayer.content.swf"
    },
    "captions": {
      "url": "http://...flowplayer.captions.swf"
    }
  }

Do I need to create a custom JSON converter for those objects or is there a better way to achieve what I want?