Blog series to teach and show off D's metaprogramming by creating a JSON serialiser
Jacob Carlborg
doob at me.com
Fri Nov 1 10:39:42 UTC 2019
On Thursday, 31 October 2019 at 00:05:06 UTC, SealabJaster wrote:
> https://bradley.chatha.dev/Home/Blog?post=JsonSerialiser1
FYI, string is a built-in type.
Regarding exercise 2. I would be very careful with deserializing
a single character from JSON. First, because JSON doesn't support
single characters. Second, you'll run into issues with Unicode.
For example, you would need to know the exact JSON content, not
just the type, to specify the type that should be deserialized.
Example:
assert(json.deserialise!char() == '😀');
The above will not work, because the type of '😀' is not `char`,
it's `dchar`. The deserialization would need to throw an
exception in this case, because '😀' won't fit in a `char`. It's
much simpler to just not allow this use case.
--
/Jacob Carlborg
More information about the Digitalmars-d-announce
mailing list