// generated file, do not modify! // {{ dateTime }} #include "{{ moduleName }}.hpp" {% for t in definitions %} template<> json toJSON<{{ t.value.dataName }}>({{ t.value.dataName }} &v) { json obj; switch (v.tag) { {% for c in t.value.constructors %} case ::{{ t.value.dataName }}::tag::{{ c.value.name }}: obj["tag"] = "{{ c.value.name }}";{% if !(c.value.fields | empty) %} { auto tv = static_cast<::data::{{ c.value.name }}&>(v);{% for f in c.value.fields %}{% if c.value.fields | hasFieldNames %} obj["{{ f.value.fieldName }}"] = toJSON(tv.{{ f.value.fieldName }});{% else %} obj["arg{{ f.index0 }}"] = toJSON(tv._{{ f.index0 }});{% endif %}{% endfor %} }{% endif %} break;{% endfor %} } return obj; } {% endfor %}