提问人:WPWPWP 提问时间:3/11/2023 最后编辑:WPWPWP 更新时间:3/18/2023 访问量:122
尝试将 JSON 文件导入 Firebase 实时数据库时出错
Error attempting to import JSON file into Firebase Realtime Database
问:
几个月前,我成功地将类似的.json文件上传到了 Firebase Realtime Database。最近我稍微修改了文件(添加键值对:“explanationImage”: “null”或“null”以外的一些值),并且在尝试导入新文件时,出现以下错误:“无效的 JSON - 键不能为空或包含 $#[]。"
然而,我在任何键中都没有看到这些字符,并且根据 JSONLint.com,该文件的 JSON 格式正确。
这是我以 UTF8 格式保存的.json文件:
{
"questionAndItsAnswers":
[
{
"id": 1,
"question": "In 2006, the International Astronomical Union (IAU) reclassified this object as a dwarf planet:",
"answerChoices": ["Pluto", "Mercury", "the Moon", "Pallas"],
"correctAnswerIndex": 0,
"hint": "Hint: The Moon is larger than any dwarf planet.",
"answerAndExplanation": "Pluto. Pluto’s former status as a planet was challenged by the discovery of similar-sized objects in the Kuiper belt.",
"explanationImage": "gs://spaceinvadersandquiz.appspot.com/Pluto14July2015NewHorizons1024x1024Qual90.jpg"
},
{
"id": 2,
"question": "This planet is a gas giant:",
"answerChoices": ["Mars", "Saturn", "Uranus", "Neptune"],
"correctAnswerIndex": 1,
"hint": "Hint: Uranus and Neptune are now usually classified as ice giants.",
"answerAndExplanation": "Saturn. Jupiter and Saturn are classified as gas giants. Mars is classified as a terrestrial planet (along with Mercury, Venus, and Earth). Uranus and Neptune are now usually classified as ice giants.",
"explanationImage": "gs://spaceinvadersandquiz.appspot.com/SaturnHubble4July2020Enceladus(below)Mimas(rt)512x512Qual90.jpg"
},
{
"id": 3,
"question": "This is the most massive object in the Solar System:",
"answerChoices": ["the asteroid belt", "the Kuiper belt", "the Sun", "solar wind"],
"correctAnswerIndex": 2,
"hint": "Hint: The asteroid belt is less massive than the Kuiper belt.",
"answerAndExplanation": "The Sun. The Sun contains approximately 99.86% of the mass of the Solar System.",
"explanationImage": "gs://spaceinvadersandquiz.appspot.com/SunAndProminenceSTEREOspacecraft29Sept2008_512x512Qual90.jpg"
},
{
"id": 4,
"question": "This planet is an ice giant:",
"answerChoices": ["Mercury", "Jupiter", "Saturn", "Uranus"],
"correctAnswerIndex": 3,
"hint": "Hint: This planet, though visible to the naked eye, was unrecognized as a planet until 1781 due to its dimness and slow apparent movement.",
"answerAndExplanation": "Uranus. Uranus and Neptune are classified as ice giant planets. Jupiter and Saturn are classified as gas giant planets. Mercury is one of the terrestrial planets.",
"explanationImage": "gs://spaceinvadersandquiz.appspot.com/UranusHubble11Dec2009BandsDarkSpot256x256Qual90.jpg"
},
{
"id": 5,
"question": "This is a terrestrial planet:",
"answerChoices": ["Venus", "Jupiter", "Neptune", "Pluto"],
"correctAnswerIndex": 0,
"hint": "Hint: Neptune is classified as an ice giant planet.",
"answerAndExplanation": "Venus. Mercury, Venus, Earth, and Mars are the terrestrial planets – planets consisting primarily of metals or silicate rocks. Jupiter and Saturn are gas giant planets. Uranus and Neptune are ice giant planets. Pluto was reclassified as a dwarf planet in 2006.",
"explanationImage": "gs://spaceinvadersandquiz.appspot.com/VenusMariner10ContrastEnhanced7Feb1974_1024x1024Qual90.jpg"
},
{
"id": 6,
"question": "The plane of the Earth’s orbit around the Sun is the:",
"answerChoices": ["equator", "ecliptic", "equinox", "ellipse"],
"correctAnswerIndex": 1,
"hint": "Hint: An equinox occurs around 20 March and 23 September when the center of the Sun is directly over the equator.",
"answerAndExplanation": "Ecliptic. For an observer on Earth, the ecliptic is the annual path of the Sun viewed against the background stars.",
"explanationImage": "null"
},
{
"id": 7,
"question": "Roughly 73% of the Sun’s mass consists of this:",
"answerChoices": ["iron", "nickel", "hydrogen", "helium"],
"correctAnswerIndex": 2,
"hint": "Hint: Helium accounts for about 25% of the Sun’s mass.",
"answerAndExplanation": "Hydrogen.",
"explanationImage": "null"
},
{
"id": 8,
"question": "The center of mass of multiple bodies orbiting each other is the:",
"answerChoices": ["orbital node", "semi-major axis", "Roche limit", "barycenter"],
"correctAnswerIndex": 3,
"hint": "Hint: This term derives from an Ancient Greek expression for ‘heavy center.’",
"answerAndExplanation": "Barycenter. The dwarf planet Pluto and its largest moon, Charon, are sometimes considered a binary system because the center of mass of their orbits, that is, their barycenter, lies between them and outside of either body, whereas the barycenter of the Earth-Moon system lies within the Earth.",
"explanationImage": "null"
},
{
"id": 9,
"question": "The nearest star system to the Sun is:",
"answerChoices": ["Alpha Centauri", "Algol", "Sirius", "Polaris"],
"correctAnswerIndex": 0,
"hint": "Hint: Polaris (also called the ‘North Star’ or ‘Pole Star’) is not especially close to the Solar System but is very close to the Earth’s celestial north pole.",
"answerAndExplanation": "Alpha Centauri. Alpha Centauri is a triple star system 4.37 light-years (1.34 parsecs) from the Sun.",
"explanationImage": "null"
},
{
"id": 10,
"question": "These objects have masses less than the least massive stars but greater than the most massive planets:",
"answerChoices": ["dwarf planets", "brown dwarfs", "star clusters", "gas giants"],
"correctAnswerIndex": 1,
"hint": "Hint: Jupiter and Saturn are gas giants (gas giant planets).",
"answerAndExplanation": "Brown dwarfs. Brown dwarfs, which are not necessarily brown, have masses from roughly 13 to 80 times that of Jupiter but lack the mass to sustain nuclear fusion. They are sometimes called ‘failed stars.’",
"explanationImage": "null"
}
]
}
提前感谢您的帮助。
答:
0赞
WPWPWP
3/18/2023
#1
不知何故,.json文件顶部附近似乎出现了错误。我最初使用 JSONLint 检查代码,但 https://jsonformatter.curiousconcept.com/# 表示错误。我通过 CodeMentor 得到了某人的帮助。无论如何,稍微重新格式化的文件已成功上传到 Firebase 数据库。我们没有用任何特殊(例如,UTF8 编码)保存它。
评论
.json