digitalmars.D - GSOC2025: Json Library for D, weekly update #8
- Gaofei (31/31) Aug 11 Since we've already established a framework for customized
Since we've already established a framework for customized deserialization and added some tests (such as case insensitivity), we now want to incorporate case insensitivity as an optional feature into the default deserialization policy. https://github.com/schveiguy/jsoniopipe/pull/54 https://github.com/schveiguy/jsoniopipe/pull/57 The insensitivity in the test is like: ```d static struct CaseInsensitivePolicy { void onField(JT, T, C)(ref JT tokenizer, ref T item, JSONItem key, ref C context) { // Case-insensitive comparison import std.string : icmp; alias members = SerializableMembers!T; auto keyStr = key.data(tokenizer.chain); static foreach(i, memberName; members) { { enum jsonName = memberName; if (icmp(keyStr, jsonName) == 0) { deserializeImpl(this, tokenizer, __traits(getMember, item, memberName)); context[i] = true; return; } } } throw new JSONIopipeException(format("No member named '%s' in type `%s`", keyStr, T.stringof)); } } ```
Aug 11