Am 23.01.2018 um 19:13 schrieb Taylor Gronka:

This kind of nesting is generally supported and, if the kind of animal is not known upfront, this is what I'd usually also do. What does the error message say?

Thanks for the help! I found the issue was my mistake - for this testing, another Json field was returning as null, which was failing. There's a flag for ignoring null values when unpacking, right? How is that done (and where is it documented)?

I see something like Nullable!Json u in these forums, but I think that's deprecated now? I think I saw another flag such as @ignore... Something like

struct animal {
   string p;
   Nullable!Json animal;
   @ignore Json animal2;

Nullable!T is still supported and makes sense for non-reference types
(e.g. structs or numbers), or if the field should actually be forced to
contain null instead of just being omitted. But other than that, I'd
usually also go with @optional.

@ignore just completely ignores a field during the whole serialization
process, so that it always ends up empty after deserializeJson, no
matter if present in the input JSON or not.