custom serializer

Hi,

I'm new to nameko and making some tests.

I now want to setup a custom serializer so I read different posts on the
subject and tried to register my serializer to kombu with

register('my_json', to_json, from_json, 'application/my_json')

My service returns a dict(v='string', on=datetime.utcnow())

and my serializer is able to serialize datetime

But when I call my service I get an error

nameko.exceptions.RemoteError: UnserializableValueError Unserializable value: `{'v': 'string', 'on': datetime.datetime(2018, 2, 27, 10, 50, 52, 648749)}`

So my question : Is it the right solution ? What did I forgot ?

Tia.

I think we would have to see what to_json does exactly to know what's going
wrong with your serialiser!

Here is what my serialiser looks like (shamelessly stolen from one of the
more helpful chaps in this very group)
-- Serialiser for nameko · GitHub -- you'd
want to remove the ServiceResult stuff if you give this a try though.

You may have figured out already, but nameko shell also requires the
serialiser to be registered.

···

On Tuesday, 27 February 2018 21:57:50 UTC+11, rejo wrote:

Hi,

I'm new to nameko and making some tests.

I now want to setup a custom serializer so I read different posts on the
subject and tried to register my serializer to kombu with

register('my_json', to_json, from_json, 'application/my_json')

My service returns a dict(v='string', on=datetime.utcnow())

and my serializer is able to serialize datetime

But when I call my service I get an error

nameko.exceptions.RemoteError: UnserializableValueError Unserializable value: `{'v': 'string', 'on': datetime.datetime(2018, 2, 27, 10, 50, 52, 648749)}`

So my question : Is it the right solution ? What did I forgot ?

Tia.