wip ref fixes
This commit is contained in:
parent
88b79e2300
commit
ee4795cf29
|
@ -2,6 +2,9 @@ import
|
|||
typetraits,
|
||||
faststreams/output_stream, serialization, json
|
||||
|
||||
import
|
||||
stew/shims/macros
|
||||
|
||||
type
|
||||
JsonWriterState = enum
|
||||
RecordExpected
|
||||
|
@ -135,6 +138,16 @@ proc writeValue*(w: var JsonWriter, value: auto) =
|
|||
elif value is ref:
|
||||
if value == nil:
|
||||
append "null"
|
||||
else:
|
||||
when value[] is object:
|
||||
w.beginRecord(type(value))
|
||||
type RecordType = type value
|
||||
value.enumInstanceSerializedFields(fieldName, field):
|
||||
type FieldType = type field
|
||||
w.writeFieldName(fieldName)
|
||||
w.writeFieldIMPL(FieldTag[RecordType, fieldName, FieldType], field, value)
|
||||
w.state = AfterField
|
||||
w.endRecord()
|
||||
else:
|
||||
writeValue(w, value[])
|
||||
elif value is string|cstring:
|
||||
|
|
Loading…
Reference in New Issue