I tried to directly encode an enum to json. I get the following error: “Top-level (T.self) encoded as number JSON fragment.”.
I looked up the corresponding source line in the Swift sources: https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/JSONEncoder.swift#L221
Judging from the code, it looks like it’s only possible to encode structs/dictionaries/arrays to json with the
JSONEncoder. Is this true?