Native Codec

For many json-like data formats, you can just use the basic native codec of the dog engine without having any problems, but for many more complex applications, you want the engine to retain specific types instead of converting them to a simpler form as they can be handled explicitly in your more . To achieve this, you want to create a custom native codec to handle/retain your native values. Just implement the DogNativeCodec interface and define a method for and a method which checks if a specific serial type is native.

The type set provided by your codec should not be smaller than the default json type set and therefore include following types: String, int, double, bool, List, Map. Null values should not be treated by the codec and must/should be allowed. Invalid map keys should also be not be handled by the codec and should be validated by the actual encoder.

You can the fork your default engine using the fork() method and specify your own codec using the named codec parameter. The resulting engine can then be used for any further operations. As you might have noticed, this is primarily intended for other packages which use dogs as their serialization backend. This includes for example orm and configuration frameworks.

Last updated