From 744ab6bacd46abf3fe0765b33681e297b43c2ace Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 20 Sep 2023 21:29:48 -0400 Subject: [PATCH] Update DataBuilder.hx --- src/json2object/writer/DataBuilder.hx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/json2object/writer/DataBuilder.hx b/src/json2object/writer/DataBuilder.hx index b7034fb..4016a79 100644 --- a/src/json2object/writer/DataBuilder.hx +++ b/src/json2object/writer/DataBuilder.hx @@ -210,11 +210,22 @@ class DataBuilder { } assignations.push(assignation); - skips.push( - field.meta.has(':optional') - ? macro $f_a == null - : macro false - ); + if (field.meta.has(':optional')) { + switch (field.type) { + case TAbstract(t, params): + if (t.toString() == "Null") { + // Null + skips.push(macro $f_a == null); + } else { + // Bool + skips.push(macro false); + } + default: + skips.push(macro $f_a == null); + } + } else { + skips.push(macro false); + } default: }