From 2dcb8426a02508649745bc1a9e18ae19c04b13ba Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 17 Jun 2020 13:37:26 +0200 Subject: [PATCH] Add JSON conversion --- lib/src/objects.dart | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/lib/src/objects.dart b/lib/src/objects.dart index 4a9e302..1e86dca 100644 --- a/lib/src/objects.dart +++ b/lib/src/objects.dart @@ -8,6 +8,12 @@ class PhraseScrapeSentence { this.japanese = japanese; this.pieces = pieces; } + + Map toJson() => { + 'english': english, + 'japanese': japanese, + 'pieces': pieces + }; } class PhraseScrapeMeaning { @@ -34,6 +40,15 @@ class PhraseScrapeMeaning { this.tags = tags; } + + Map toJson() => { + 'seeAlsoTerms': seeAlsoTerms, + 'sentences': sentences, + 'definition': definition, + 'supplemental': supplemental, + 'definitionAbstract': definitionAbstract, + 'tags': tags + }; } class KanjiKanaPair { @@ -47,34 +62,50 @@ class KanjiKanaPair { this.kanji = kanji; this.kana = kana; } + + Map toJson() => { + 'kanji': kanji, + 'kana': kana + }; } class PhrasePageScrapeResult { bool found; String query; String uri; - List otherForms; - List meanings; List tags; + List meanings; + List otherForms; List notes; PhrasePageScrapeResult({ bool found, String query, String uri, - List otherForms, - List meanings, List tags, + List meanings, + List otherForms, List notes, }){ this.found = found; this.query = query; this.uri = uri; - this.otherForms = otherForms; - this.meanings = meanings; this.tags = tags; + this.meanings = meanings; + this.otherForms = otherForms; this.notes = notes; } + + Map toJson() => + { + 'found': found, + 'query': query, + 'uri': uri, + 'tags': tags, + 'meanings': meanings, + 'otherForms': otherForms, + 'notes': notes + }; } class YomiExample {