import Foundation enum E: Codable { case a(Int???) } let encoder = JSONEncoder() encoder.outputFormatting = .prettyPrinted let value: [E] = [ .a(.none), .a(.some(.none)), .a(.some(.some(.none))), .a(.some(.some(.some(1)))) ] let json = try encoder.encode(value) print(String(data: json, encoding: .utf8)!)
(edited)