# [answered] Component objects with data driven design

This topic is 1344 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey folks,

I'm messing around with a small project in my spare time (a 2D editor using Monogame), and am in the process of designing a data driven component-object system.

So the basic idea is that at runtime the editor parses all JSON files in a project's data directory, adding each Object to a content library. Users in the editor will be able open up the content browser and drag/drop objects in to the game world... all fairly simple stuff.

The objects in my engine are component based. The engine defines a set of fairly common components (graphic/physics/audio) but what I'd like to be able to do is have the JSON files define components that are unique to the Game... class types that the editor isn't aware of.

As an example :

{
"class" : "Object",
"Name" : "Jim",
"Health" : "50",
"Components" : [
{
"class" : "GraphicComponent",  // defined by Engine
"image" : "jim.png"
},
{
"class" : "PlayerController",  // defined by Game
}
]
}


So my question comes down to how to handle this in the editor when I'm deserializing this Object... obviously the editor isn't going to know what to do with the PlayerController class, and I don't want to throw a bunch of exceptions when trying to load an object.

I'm looking at using JSON.NET, and was wondering if it's possible to build a custom deserializer so I can just ignore any class types that the editor doesn't know about?

Edited by Orangeatang

##### Share on other sites

Ah, looks like you can do partial JSON deserialization in JSON.NET. That took all of two minutes to research... sorry for wasting your time!

• 18
• 11
• 17
• 9
• 51
• ### Forum Statistics

• Total Topics
631397
• Total Posts
2999793
×