So in the Base object, there are several lists which in turn contain several other objects. Those are not of type Base, but we have assigned custom type names. Should I create my own deserializer for those?
For those additional objects to work well in Speckle you should have them inherit from Base, if you do so, there is no need for custom serializer and the Speckle one should do all the magic for you (at least in Grasshopper).
you can create any custom classes that inherit from Baseand to answer your question you’ll have to in order to preserve the classes (the data structure and data will remain intact though), but the serialiser won’t know about them unless they’re available as part of a Kit.
Using @teocomi’s strategy won’t really work, as the deserialiser will default to Base if it can’t find a matching speckle type in any of the available kits.
See here, a custom class created in a script will be properly serialised, but deserialised into it’s generic Base form.
In order to preserve your own classes, you’ll need to create a Kit (no need to have conversions if they’re not necessary).
And here’s a super raw implementation of a kit with just one object:
You’ll need to copy over the kit to your own directory inside %appdata%/Speckle/Kits/YOUR_KIT_NAME, we usually do this with a post-build step. Here’s the one of the example that works for Mac and Windows
Hopefully that will get you on the right track!
PS: How exactly are you getting those objects in grasshopper? If its through a Speckle Stream, could you share it with us?
Ah! Thanks for the extensive reply. I am getting the objects from an api server, that converts a json of Karamba to our company’s FEM schema. The FEM schema objects are returned by the endpoint as serialized Speckle objects.
I’m trying to create a GH component that takes in a Karamba json, and outputs all the Speckle objects. For now, I was trying to do the deserialization in C#.
Like you suggest, I’ll try to output the raw json from the component now, and see if the Deserialize component does the job!