From 0194e3a7a0648bfa1b46bdb500c26d2b0edd64a5 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 17 Jun 2020 10:17:40 +0200 Subject: [PATCH] Remove conditional JSON --- lib/src/objects.dart | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/src/objects.dart b/lib/src/objects.dart index 8af0714..4a9e302 100644 --- a/lib/src/objects.dart +++ b/lib/src/objects.dart @@ -111,9 +111,9 @@ class Radical { Map toJson() => { - if (symbol != null) 'symbol': symbol, - if (forms != null) 'forms': forms, - if (meaning != null) 'meaning': meaning + 'symbol': symbol, + 'forms': forms, + 'meaning': meaning }; } @@ -152,7 +152,7 @@ class KanjiResult { 'found': found, 'taughtIn': taughtIn, 'jlptLevel': jlptLevel, - 'newspaperFrequencyRank': newspaperFrequencyRank.toString(), // TODO: Rewrite tests to make this value an int + 'newspaperFrequencyRank': newspaperFrequencyRank, 'strokeCount': strokeCount, 'meaning': meaning, 'kunyomi': kunyomi, @@ -166,9 +166,6 @@ class KanjiResult { 'strokeOrderGifUri': strokeOrderGifUri, 'uri': uri }; - - if (newspaperFrequencyRank == null) returnObject.update('newspaperFrequencyRank', (value) => null); - returnObject.removeWhere((key, value) => value == null); return returnObject; } @@ -185,8 +182,8 @@ class ExampleSentencePiece { Map toJson() { return { - if (lifted != null) 'lifted': lifted, - if (unlifted != null)'unlifted': unlifted + 'lifted': lifted, + 'unlifted': unlifted }; } }