Fixed JishoAttribution bool value parsing

This commit is contained in:
Oystein Kristoffer Tveit 2020-06-24 01:52:11 +02:00
parent 0f606b7d1b
commit 1dc3a388d4
2 changed files with 7 additions and 8 deletions

View File

@ -364,7 +364,7 @@ class JishoWordSense {
class JishoAttribution { class JishoAttribution {
bool jmdict; bool jmdict;
bool jmnedict; bool jmnedict;
bool dbpedia; bool dbpedia; //This variable might be returned as a link (String). Not sure about the above
JishoAttribution({ JishoAttribution({
this.jmdict, this.jmdict,
@ -373,10 +373,10 @@ class JishoAttribution {
}); });
factory JishoAttribution.fromJson(Map<String, dynamic> json){ factory JishoAttribution.fromJson(Map<String, dynamic> json){
return JishoAttribution( //TODO: This is broken. Find the potential values of a json result and fix return JishoAttribution(
jmdict: (json['jmdict'] == 'true'), jmdict: (json['jmdict'].toString() == 'true'),
jmnedict: (json['jmnedict'] == 'true'), jmnedict: (json['jmnedict'].toString() == 'true'),
dbpedia: (json['dbpedia'] == 'true') dbpedia: (json['dbpedia'].toString() == 'true')
); );
} }

View File

@ -18,10 +18,9 @@ class JishoApi {
/// @returns {Object} The response data from the official Jisho.org API. Its format is somewhat /// @returns {Object} The response data from the official Jisho.org API. Its format is somewhat
/// complex and is not documented, so put on your trial-and-error hat. /// complex and is not documented, so put on your trial-and-error hat.
/// @async /// @async
Future<List<JishoResult>> searchForPhrase(String phrase) async { Future<JishoAPIResult> searchForPhrase(String phrase) async {
final uri = uriForPhraseSearch(phrase); final uri = uriForPhraseSearch(phrase);
final jsonData = await http.get(uri).then((response) => JishoAPIResult.fromJson(jsonDecode(response.body))); return await http.get(uri).then((response) => JishoAPIResult.fromJson(jsonDecode(response.body)));
return jsonData.data;
} }
/// Scrape Jisho.org for information about a kanji character. /// Scrape Jisho.org for information about a kanji character.