Add JSON conversion

This commit is contained in:
Oystein Kristoffer Tveit 2020-06-17 13:37:26 +02:00
parent 55390c0d0f
commit 2dcb8426a0
1 changed files with 37 additions and 6 deletions

View File

@ -8,6 +8,12 @@ class PhraseScrapeSentence {
this.japanese = japanese; this.japanese = japanese;
this.pieces = pieces; this.pieces = pieces;
} }
Map<String, dynamic> toJson() => {
'english': english,
'japanese': japanese,
'pieces': pieces
};
} }
class PhraseScrapeMeaning { class PhraseScrapeMeaning {
@ -34,6 +40,15 @@ class PhraseScrapeMeaning {
this.tags = tags; this.tags = tags;
} }
Map<String, dynamic> toJson() => {
'seeAlsoTerms': seeAlsoTerms,
'sentences': sentences,
'definition': definition,
'supplemental': supplemental,
'definitionAbstract': definitionAbstract,
'tags': tags
};
} }
class KanjiKanaPair { class KanjiKanaPair {
@ -47,34 +62,50 @@ class KanjiKanaPair {
this.kanji = kanji; this.kanji = kanji;
this.kana = kana; this.kana = kana;
} }
Map<String, String> toJson() => {
'kanji': kanji,
'kana': kana
};
} }
class PhrasePageScrapeResult { class PhrasePageScrapeResult {
bool found; bool found;
String query; String query;
String uri; String uri;
List<KanjiKanaPair> otherForms;
List<PhraseScrapeMeaning> meanings;
List<String> tags; List<String> tags;
List<PhraseScrapeMeaning> meanings;
List<KanjiKanaPair> otherForms;
List<String> notes; List<String> notes;
PhrasePageScrapeResult({ PhrasePageScrapeResult({
bool found, bool found,
String query, String query,
String uri, String uri,
List<KanjiKanaPair> otherForms,
List<PhraseScrapeMeaning> meanings,
List<String> tags, List<String> tags,
List<PhraseScrapeMeaning> meanings,
List<KanjiKanaPair> otherForms,
List<String> notes, List<String> notes,
}){ }){
this.found = found; this.found = found;
this.query = query; this.query = query;
this.uri = uri; this.uri = uri;
this.otherForms = otherForms;
this.meanings = meanings;
this.tags = tags; this.tags = tags;
this.meanings = meanings;
this.otherForms = otherForms;
this.notes = notes; this.notes = notes;
} }
Map<String, dynamic> toJson() =>
{
'found': found,
'query': query,
'uri': uri,
'tags': tags,
'meanings': meanings,
'otherForms': otherForms,
'notes': notes
};
} }
class YomiExample { class YomiExample {