ParsedObject¶
- class freedictionaryapi.types.base.ParsedObject(data: dict)[source]¶
Bases:
abc.ABCImplements base parsed object. Means part of API json response that is structured by category and has inner fields.
Class gives convenient base for inheriting and creating more concrete types, so inherited classes parse more detailed information and might be used in composition with the others.
Must be inherited since it is abstract.
- For example, in response of dictionary API it might be:
phonetics;
meanings;
definitions.
Considering that simple response might look like that (copied from https://dictionaryapi.dev/):
1[ 2 { 3 "word": "hello", 4 "phonetics": [ 5 { 6 "text": "/həˈloʊ/", 7 "audio": "https://lex-audio.useremarkable.com/mp3/hello_us_1_rr.mp3" 8 }, 9 { 10 "text": "/hɛˈloʊ/", 11 "audio": "https://lex-audio.useremarkable.com/mp3/hello_us_2_rr.mp3" 12 } 13 ], 14 "meanings": [ 15 { 16 "partOfSpeech": "exclamation", 17 "definitions": [ 18 { 19 "definition": "Used as a greeting or to begin a phone conversation.", 20 "example": "hello there, Katie!" 21 } 22 ] 23 }, 24 { 25 "partOfSpeech": "noun", 26 "definitions": [ 27 { 28 "definition": "An utterance of “hello”; a greeting.", 29 "example": "she was getting polite nods and hellos from people", 30 "synonyms": [ 31 "greeting", 32 "welcome", 33 "salutation", 34 "saluting", 35 "hailing", 36 "address", 37 "hello", 38 "hallo" 39 ] 40 } 41 ] 42 }, 43 { 44 "partOfSpeech": "intransitive verb", 45 "definitions": [ 46 { 47 "definition": "Say or shout “hello”; greet someone.", 48 "example": "I pressed the phone button and helloed" 49 } 50 ] 51 } 52 ] 53 } 54]
- __init__(data: dict) → None[source]¶
Init parsed object instance. Get data presented in python
dictand set it in instance (with_dataparam).- Parameters
data (
dict) – part of API json response
- property data: dict¶
- Returns
Data of the parsed object
- Return type
dict