#1 2023-03-15 14:52:47

stuart
Member
Registered: 2022-03-08
Posts: 6

Default JSON serialisation of character types

Is there a way to customise the default JSON serialisation of character types?  Specifically, I'd like them to be serialised to JSON strings rather than numbers and wondered if there are any options for this?

I know I can register a custom serialiser using TRttiJson.RegisterCustomSerializer, but then I need to do this for each distinct character type, so a way to customise the default would be preferable.

Offline

#2 2023-03-17 08:26:32

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Default JSON serialisation of character types

My guess is that JSON serialization of character types into numbers was not correct.
Even mORMot 1 generated JSON strings.

Please try https://github.com/synopse/mORMot2/commit/c18ba13a

Online

#3 2023-03-17 12:54:25

stuart
Member
Registered: 2022-03-08
Posts: 6

Re: Default JSON serialisation of character types

Thanks, character types are now being serialised as strings, although it doesn't currently escape control characters.

Offline

#4 2023-03-18 08:19:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Default JSON serialisation of character types

Online

#5 2023-03-20 09:50:26

stuart
Member
Registered: 2022-03-08
Posts: 6

Re: Default JSON serialisation of character types

That's fixed it, thanks!

Offline

Board footer

Powered by FluxBB