Skip to content

Commit 7f578f8

Browse files
committed
Update README
1 parent c75f252 commit 7f578f8

File tree

3 files changed

+83
-58
lines changed

3 files changed

+83
-58
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.1
2+
3+
- Fixed the readme
4+
15
## 2.0.0
26

37
- Upgrade library to use null-safety

README.md

Lines changed: 78 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,25 @@ import 'package:unofficial_jisho_api/api.dart' as jisho;
3636
void main() async {
3737
await jisho.searchForKanji('語').then((result) {
3838
print('Found: ${result.found}');
39-
print('Taught in: ${result.taughtIn}');
40-
print('JLPT level: ${result.jlptLevel}');
41-
print('Newspaper frequency rank: ${result.newspaperFrequencyRank}');
42-
print('Stroke count: ${result.strokeCount}');
43-
print('Meaning: ${result.meaning}');
44-
print('Kunyomi: ${jsonEncode(result.kunyomi)}');
45-
print('Kunyomi example: ${jsonEncode(result.kunyomiExamples[0])}');
46-
print('Onyomi: ${jsonEncode(result.onyomi)}');
47-
print('Onyomi example: ${jsonEncode(result.onyomiExamples[0])}');
48-
print('Radical: ${jsonEncode(result.radical)}');
49-
print('Parts: ${jsonEncode(result.parts)}');
50-
print('Stroke order diagram: ${result.strokeOrderDiagramUri}');
51-
print('Stroke order SVG: ${result.strokeOrderSvgUri}');
52-
print('Stroke order GIF: ${result.strokeOrderGifUri}');
53-
print('Jisho Uri: ${result.uri}');
39+
40+
final data = result.data;
41+
if (data != null) {
42+
print('Taught in: ${data.taughtIn}');
43+
print('JLPT level: ${data.jlptLevel}');
44+
print('Newspaper frequency rank: ${data.newspaperFrequencyRank}');
45+
print('Stroke count: ${data.strokeCount}');
46+
print('Meaning: ${data.meaning}');
47+
print('Kunyomi: ${jsonEncode(data.kunyomi)}');
48+
print('Kunyomi example: ${jsonEncode(data.kunyomiExamples[0])}');
49+
print('Onyomi: ${jsonEncode(data.onyomi)}');
50+
print('Onyomi example: ${jsonEncode(data.onyomiExamples[0])}');
51+
print('Radical: ${jsonEncode(data.radical)}');
52+
print('Parts: ${jsonEncode(data.parts)}');
53+
print('Stroke order diagram: ${data.strokeOrderDiagramUri}');
54+
print('Stroke order SVG: ${data.strokeOrderSvgUri}');
55+
print('Stroke order GIF: ${data.strokeOrderGifUri}');
56+
print('Jisho Uri: ${data.uri}');
57+
}
5458
});
5559
}
5660
```
@@ -143,45 +147,53 @@ This outputs the following:
143147
{
144148
"found": true,
145149
"query": "",
146-
"uri": "https://jisho.org/word/%E8%B0%B7",
147-
"tags": [
148-
"Common word",
149-
"JLPT N3",
150-
"Wanikani level 5"
151-
],
152-
"meanings": [
153-
{
154-
"seeAlsoTerms": [],
155-
"sentences": [],
156-
"definition": "valley",
157-
"supplemental": [],
158-
"definitionAbstract": null,
159-
"tags": [
160-
"noun"
161-
]
162-
},
163-
{
164-
"seeAlsoTerms": [],
165-
"sentences": [],
166-
"definition": "Valley",
167-
"supplemental": [],
168-
"definitionAbstract": "In geology, a valley or dale is a depression with predominant extent in one direction. A very deep river valley may be called a canyon or gorge. The terms U-shaped and V-shaped are descriptive terms of geography to characterize the form of valleys. Most valleys belong to one of these two main types or a mixture of them, (at least) with respect of the cross section of the slopes or hillsides.",
169-
"tags": [
170-
"wikipedia definition"
171-
]
172-
}
173-
],
174-
"otherForms": [
175-
{
176-
"kanji": "",
177-
"kana": "たに"
178-
},
179-
{
180-
"kanji": "谿",
181-
"kana": "たに"
182-
}
183-
],
184-
"notes": []
150+
"data": {
151+
"uri": "https://jisho.org/word/%E8%B0%B7",
152+
"tags": [
153+
"Common word",
154+
"JLPT N3",
155+
"Wanikani level 5"
156+
],
157+
"meanings": [
158+
{
159+
"seeAlsoTerms": [],
160+
"sentences": [],
161+
"definition": "valley",
162+
"supplemental": [],
163+
"definitionAbstract": null,
164+
"tags": []
165+
},
166+
{
167+
"seeAlsoTerms": [],
168+
"sentences": [],
169+
"definition": "Valley",
170+
"supplemental": [],
171+
"definitionAbstract": "In geology, a valley or dale is a depression with predominant extent in one direction. A very deep river valley may be called a canyon or gorge. The terms U-shaped and V-shaped are descriptive terms of geography to characterize the form of valleys. Most valleys belong to one of these two main types or a mixture of them, (at least) with respect of the cross section of the slopes or hillsides.",
172+
"tags": []
173+
}
174+
],
175+
"otherForms": [
176+
{
177+
"kanji": "",
178+
"kana": "たに"
179+
},
180+
{
181+
"kanji": "谿",
182+
"kana": "たに"
183+
}
184+
],
185+
"audio": [
186+
{
187+
"uri": "https://d1vjc5dkcd3yh2.cloudfront.net/audio/b9ff4f25c7a20f0f39131b3e3db0cd19.mp3",
188+
"mimetype": "audio/mpeg"
189+
},
190+
{
191+
"uri": "https://d1vjc5dkcd3yh2.cloudfront.net/audio_ogg/b9ff4f25c7a20f0f39131b3e3db0cd19.ogg",
192+
"mimetype": "audio/ogg"
193+
}
194+
],
195+
"notes": []
196+
}
185197
}
186198
```
187199

@@ -204,9 +216,12 @@ final String searchURI = jisho_parser.uriForKanjiSearch(searchKanji);
204216
void main() async {
205217
await http.get(searchURI).then((result) {
206218
final parsedResult = jisho_parser.parseKanjiPageData(result.body, searchKanji);
207-
print('JLPT level: ${parsedResult.jlptLevel}');
208-
print('Stroke count: ${parsedResult.strokeCount}');
209-
print('Meaning: ${parsedResult.meaning}');
219+
final data = parsedResult.data;
220+
if (data != null) {
221+
print('JLPT level: ${data.jlptLevel}');
222+
print('Stroke count: ${data.strokeCount}');
223+
print('Meaning: ${data.meaning}');
224+
}
210225
});
211226
}
212227
```
@@ -257,3 +272,9 @@ void main() async {
257272
## About
258273

259274
Permission to scrape granted by Jisho's admin Kimtaro: https://jisho.org/forum/54fefc1f6e73340b1f160000-is-there-any-kind-of-search-api
275+
276+
## Notes
277+
278+
The null-safety of dart 2.12 makes the parsing and interpreting of the native search API a little unreliable. Please be cautious when using `jisho.searchForPhrase()`, and if you do, please read the [API docs][api-docs] about the different result values.
279+
280+
[api-docs]: https://pub.dev/documentation/unofficial_jisho_api/latest/

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: unofficial_jisho_api
2-
version: 2.0.0
2+
version: 2.0.1
33

44
description: An unofficial api for searching and scraping the japanese dictionary Jisho.org
55
homepage: https://github.com/h7x4ABk3g/unofficial_jisho_api_dart/

0 commit comments

Comments
 (0)