【问题标题】:store large json jext in variable in android studio (kotlin)将大型 json jext 存储在 android studio (kotlin) 中的变量中
【发布时间】: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

标签: android json kotlin


【解决方案1】:

如果您不需要编辑此长文本,您可以将其存储为资产.txt 文件。在https://developer.android.com/reference/android/content/res/AssetManager中查看更多信息

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-11
    • 2018-09-23
    • 2017-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多