I want to extract the values of the key called ‘sentence’ of this json:
{"title": "llamar | Definiciu00f3n | Diccionario de la lengua espau00f1ola | RAE - ASALE", "articles": [{"id": "NTReP1j", "lema": {"lema": "llamar", "index": 0, "female_suffix": ""}, "supplementary_info": [{"text": "Del lat. (latu00edn) clamu0101re."}], "is": {"verb": true}, "definitions": [{"index": 1, "category": {"abbr": "tr.", "text": "verbo transitivo"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [], "sentence": {"text": "Intentar captar la atenciu00f3n de alguien mediante voces, ruidos o gestos."}, "examples": []}, {"index": 2, "category": {"abbr": "tr.", "text": "verbo transitivo"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [{"abbr": "U. t. c. intr.", "text": "Usado tambiu00e9n como intransitivo"}], "sentence": {"text": "Realizar las operaciones necesarias para establecer comunicaciu00f3n telefu00f3nica con alguien."}, "examples": [{"text": "La llamu00e9, pero no estaba en casa."}, {"text": "Llama a su oficina."}]}, {"index": 3, "category": {"abbr": "tr.", "text": "verbo transitivo"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [], "sentence": {"text": "Invocar, pedir auxilio a alguien."}, "examples": []}, {"index": 4, "category": {"abbr": "tr.", "text": "verbo transitivo"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [{"abbr": "U. t. c. intr.", "text": "Usado tambiu00e9n como intransitivo"}], "sentence": {"text": "Pedir a alguien que vaya a un lugar."}, "examples": [{"text": "Llamar al mu00e9dico, a los refuerzos."}, {"text": "Llamar a reuniu00f3n."}]}, {"index": 5, "category": {"abbr": "tr.", "text": "verbo transitivo"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [], "sentence": {"text": "Despertar a alguien."}, "examples": []}, {"index": 6, "category": {"abbr": "tr.", "text": "verbo transitivo"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [{"abbr": "U. t. c. intr.", "text": "Usado tambiu00e9n como intransitivo"}], "sentence": {"text": "Incitar a alguien a que se comporte de una determinada manera."}, "examples": [{"text": "Llamar a la desobediencia civil."}]}, {"index": 7, "category": {"abbr": "tr.", "text": "verbo transitivo"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [], "sentence": {"text": "Dar a alguien o algo como denominaciu00f3n o calificativo la palabra o enunciado que se expresa."}, "examples": [{"text": "Acu00e1 llamamos celular a lo que allu00e1 llaman mu00f3vil."}, {"text": "Ahora llaman dou00f1a Ana a Anita."}, {"text": "Lo llaman orgulloso."}]}, {"index": 8, "category": {"abbr": "tr.", "text": "verbo transitivo"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [], "sentence": {"text": "Dar a alguien el tratamiento que se expresa."}, "examples": [{"text": "Llu00e1mame de tu00fa."}]}, {"index": 9, "category": {"abbr": "tr.", "text": "verbo transitivo"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [], "sentence": {"text": "Designar a alguien para ocupar un puesto, desempeu00f1ar un cargo o ejercer un derecho."}, "examples": [{"text": "Fue llamada a suceder a su hermano."}]}, {"index": 10, "category": {"abbr": "tr.", "text": "verbo transitivo"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [], "sentence": {"text": "Atraer a alguien o algo."}, "examples": [{"text": "El chocolate no me llama en absoluto."}]}, {"index": 11, "category": {"abbr": "intr.", "text": "verbo intransitivo"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [], "sentence": {"text": "Hacer una seu00f1al sonora en una puerta, golpeu00e1ndola o accionando un instrumento sonoro, para que alguien la abra."}, "examples": []}, {"index": 12, "category": {"abbr": "prnl.", "text": "verbo pronominal"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [], "sentence": {"text": "Tener el nombre o la denominaciu00f3n que se expresa."}, "examples": []}, {"index": 13, "category": {"abbr": "prnl.", "text": "verbo pronominal"}, "is": {"adjective": false, "adverb": false, "interjection": false, "noun": false, "pronoun": false, "verb": true}, "abbreviations": [{"abbr": "Mar.", "text": "Marina"}, {"abbr": "desus.", "text": "desusado"}], "sentence": {"text": "Dicho del viento: Cambiar de direcciu00f3n hacia la parte que se expresa."}, "examples": []}], "complex_forms": [], "other_entries": [{"text": "treta del llamar", "link": "https://dle.rae.es/?id=abLU9KP#40fzk3z"}], "conjugations": {"verb": "llamar", "conjugations": {"Formas no personales": {"Infinitivo": "", "Gerundio": "", "Participio": "", "": "llamado"}, "Indicativo": {"Presente": {"yo": "llamo", "tu00fa / vos": ["llamas", "llamu00e1s"], "usted": "llama", "u00e9l, ella": "llama", "nosotros, nosotras": "llamamos", "vosotros, vosotras": "llamu00e1is", "ustedes": "llaman", "ellos, ellas": "llaman"}, "Copretu00e9rito": {"yo": "llamaba", "tu00fa / vos": "llamabas", "usted": "llamaba", "u00e9l, ella": "llamaba", "nosotros, nosotras": "llamu00e1bamos", "vosotros, vosotras": "llamabais", "ustedes": "llamaban", "ellos, ellas": "llamaban"}, "Pretu00e9rito": {"yo": "llamu00e9", "tu00fa / vos": "llamaste", "usted": "llamu00f3", "u00e9l, ella": "llamu00f3", "nosotros, nosotras": "llamamos", "vosotros, vosotras": "llamasteis", "ustedes": "llamaron", "ellos, ellas": "llamaron"}, "Futuro": {"yo": "llamaru00e9", "tu00fa / vos": "llamaru00e1s", "usted": "llamaru00e1", "u00e9l, ella": "llamaru00e1", "nosotros, nosotras": "llamaremos", "vosotros, vosotras": "llamaru00e9is", "ustedes": "llamaru00e1n", "ellos, ellas": "llamaru00e1n"}, "Pospretu00e9rito": {"yo": "llamaru00eda", "tu00fa / vos": "llamaru00edas", "usted": "llamaru00eda", "u00e9l, ella": "llamaru00eda", "nosotros, nosotras": "llamaru00edamos", "vosotros, vosotras": "llamaru00edais", "ustedes": "llamaru00edan", "ellos, ellas": "llamaru00edan"}}, "Subjuntivo": {"Presente": {"yo": "llame", "tu00fa / vos": "llames", "usted": "llame", "u00e9l, ella": "llame", "nosotros, nosotras": "llamemos", "vosotros, vosotras": "llamu00e9is", "ustedes": "llamen", "ellos, ellas": "llamen"}, "Futuro": {"yo": "llamare", "tu00fa / vos": "llamares", "usted": "llamare", "u00e9l, ella": "llamare", "nosotros, nosotras": "llamu00e1remos", "vosotros, vosotras": "llamareis", "ustedes": "llamaren", "ellos, ellas": "llamaren"}, "Copretu00e9rito": {}, "": {"yo": ["llamara", "llamase"], "tu00fa / vos": ["llamaras", "llamases"], "usted": ["llamara", "llamase"], "u00e9l, ella": ["llamara", "llamase"], "nosotros, nosotras": ["llamu00e1ramos", "llamu00e1semos"], "vosotros, vosotras": ["llamarais", "llamaseis"], "ustedes": ["llamaran", "llamasen"], "ellos, ellas": ["llamaran", "llamasen"]}}, "Imperativo": {"": {"tu00fa / vos": ["llama", "llamu00e1"], "usted": "llame", "vosotros, vosotras": "llamad", "ustedes": "llamen"}}}}}]}
By the moment I only was able to convert the dic to json:
from pyrae import dle
import json
res = dle.search_by_word(word='llamar')
res = res.to_dict()
json_string = json.dumps(res)
data = json.loads(json_string)
print(data['sentence']) # throws error
This library pyrae allows me to get meaning of a spanish word.
I will appreciate any idea guys to solve it,
thanks so much.
4
Answers
JSON read the json string to python’s dict and You need to go through every indirect object.
If you want get every value in above example u need to iterate over every obj in
B
arra/list just lik:Your example is too large so i show you the answer on my own, smaller one.
Output:
Since I assume the depth of the dict is unknown and it and the values can be text,dict,list , you will have to use a recursion function
Directly from the dictionary it can be extracted like this:
Result:
If more than one "sentence" it would be necessary to go through it with a loop
Resultado: