|
10 | 10 | import |
11 | 11 | serialization/[formats, object_serialization] |
12 | 12 |
|
13 | | -export |
14 | | - formats |
| 13 | +export formats |
15 | 14 |
|
16 | 15 | serializationFormat Json, |
17 | 16 | mimeType = "application/json" |
@@ -60,12 +59,15 @@ template createJsonFlavor*(FlavorName: untyped, |
60 | 59 | omitOptionalFields = true, |
61 | 60 | allowUnknownFields = true, |
62 | 61 | skipNullFields = false) {.dirty.} = |
63 | | - type FlavorName* = object |
| 62 | + when declared(SerializationFormat): # Earlier versions lack mimeTypeValue |
| 63 | + createFlavor(Json, FlavorName, mimeTypeValue) |
| 64 | + else: |
| 65 | + type FlavorName* = object |
64 | 66 |
|
65 | | - template Reader*(T: type FlavorName): type = Reader(Json, FlavorName) |
66 | | - template Writer*(T: type FlavorName): type = Writer(Json, FlavorName) |
67 | | - template PreferredOutputType*(T: type FlavorName): type = string |
68 | | - template mimeType*(T: type FlavorName): string = mimeTypeValue |
| 67 | + template Reader*(T: type FlavorName): type = Reader(Json, FlavorName) |
| 68 | + template Writer*(T: type FlavorName): type = Writer(Json, FlavorName) |
| 69 | + template PreferredOutputType*(T: type FlavorName): type = string |
| 70 | + template mimeType*(T: type FlavorName): string = mimeTypeValue |
69 | 71 |
|
70 | 72 | template flavorUsesAutomaticObjectSerialization*(T: type FlavorName): bool = automaticObjectSerialization |
71 | 73 | template flavorOmitsOptionalFields*(T: type FlavorName): bool = omitOptionalFields |
|
0 commit comments