【发布时间】:2022-01-06 07:22:39
【问题描述】:
我有一个包含 MCQ 的至少 2500 行 的大型 json 文本,如下所示:
[[
"Cellular respiration is defined as:",
" An intracellular, energy-producing process",
" An extracellular, energy-producing process",
" An intracellular, energy-requiring process",
" An extracellular, energy-requiring process",
],[
"The physiological term for eating and drinking is:",
"Ingestion.",
"Propulsion.",
"Absorption.",
"Digestion.",
],[
"Nerve impulses:",
"Can travel either way along a neurone.",
"Travel more quickly in unmyelinated neurones.",
"Travel by saltatory conduction in myelinated neurones.",
"Travel during the refractory period.",
],[
"Which of the following is referred to as internal environment?",
"Intracellular fluid",
"Plasma",
"Cytosol",
"Extracellular fluid",
],[
"The two tiny openings in the laryngopharynx communicate with:",
"The oropharynx.",
"The maxillary sinus.",
"The middle ear.",
"The ethmoid sinus.",
],[
"Pontine area works opposite to:",
"Medullary area",
"Cortex",
"Red nucleus",
"Vestibular area",
],[
"In nerve cells:",
"The cell membrane is polarised in the resting state.",
"Sodium (Na+) is the principal intracellular cation.",
"At rest, Na+ tends to diffuse out of the cells.",
"Depolarisation occurs when Na+ floods out of the cells."]]
我想将此文本存储到字符串变量中,然后将其转换为 json 对象。我试过这样做:
val jsonString = "......large-text....."
但是当我将该文本粘贴到“jsonString”中时,它会阻塞整个 android studio,我如何将该文本存储在变量中??
【问题讨论】:
-
更好的方法只需在 assets 文件夹下创建一个
.json文件,并在需要时阅读它here it is。