Issue
First and foremost, I'd like to address that JSON is fairly new to me so expect my code to look faulty. I have a JSON object that defines two clubs: "Oak Club" and "Bravo Club" with its members. Note, that this code was written in Python.
Here is the JSON object:
json_clubs = {
"clubs": [
{
"Oak Club": {
"members": [
"Charles",
"Nora",
"Tom",
"Paul"
]
}
}
],
[
{
"Bravo Club": {
"members": [
"Nathaniel",
"Roselyn",
"Ash"
]
}
}
]
}
This code raises the syntax error: ':' expected after dictionary key.
VSCode highlights the "clubs" key-value pair and states: End of file expected.
After inspecting my code, I can't seem to figure out where I went wrong since all my keys have colons separating keys from their values.
Solution
You are trying to map clubs
to two separate arrays (each containing a single object), rather than a single array with two objects.
json_clubs = {
"clubs": [
{
"Oak Club": {
"members": [
"Charles",
"Nora",
"Tom",
"Paul"
]
}
},
{
"Bravo Club": {
"members": [
"Nathaniel",
"Roselyn",
"Ash"
]
}
}
]
}
Answered By - chepner Answer Checked By - Candace Johnson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.