gpt4 book ai didi

javascript - 我正在尝试使用 JSON 存储音乐专辑

转载 作者:行者123 更新时间:2023-11-30 21:05:19 24 4
gpt4 key购买 nike

这就是我所拥有的。我需要的是2张专辑,每张至少4首歌曲。专辑应包括:专辑名称、艺术家姓名、发行年份。歌曲信息应包括:歌曲名称、播放时间

歌曲应表示为对象数组。

到目前为止,这些都是我用代码编写的相册。我认为这是不正确的,但我不确定如何解决。当我通过 JSON 检查器运行它时,它给我错误

album1 = { 
"title" : "The Avairy”,
"artist" : "Galantis”,
"year_released" : 2017,
“songs”:[{
"song1” : "Hey Alligator”,
"songtime1” : 197,
“song2” : “True Feeling”,
“songtime2”: 214,
“song3” : “Written in the scars”
“songtime3” : 194,
“song4” : “No Money”
“songtime4” : 185;
}]
}

album2 = {
"title" : “Kolony”,
"artist" : “Steve Aoki”,
"year_released" : 2017,
“songs”:[
"song1” : “Lit”,
"songtime1” : 150,
“song2” : “Without you”,
“songtime2”: 207,
“song3” : “Been Ballin”
“songtime3” : 180,
“song4” : “How Else”
“songtime4” : 152;
]
}

最佳答案

您的 JSON 格式存在各种问题:

  • 不能有分号

  • 对象中缺少逗号

  • 你有一些奇怪的双引号(不是常规的 ")

您可以使用例如 https://jsonlint.com/ 验证您的 json .

{
"title": "The Avairy",
"artist": "Galantis",
"year_released": 2017,
"songs": [{
"song1": "Hey Alligator",
"songtime1": 197,
"song2": "True Feeling",
"songtime2": 214,
"song3": "Written in the scars",
"songtime3": 194,
"song4": "No Money",
"songtime4": 185
}]
}

{
"title": "Kolony",
"artist": "Steve Aoki",
"year_released": 2017,
"songs": [{
"song1": "Lit",
"songtime1": 150,
"song2": "Without you",
"songtime2": 207,
"song3": "Been Ballin",
"songtime3": 180,
"song4": "How Else",
"songtime4": 152
}]
}

顺便说一句,我发现这种建模专辑数据的方式很奇怪。为什么不是这样的:

[{
"title": "The Avairy",
"artist": "Galantis",
"year_released": 2017,
"songs": [{
"title": "Hey Alligator",
"length": 197
},
{
"title": "True Feeling",
"length": 214
},
{
"title": "Written in the scars",
"length": 194
},
{
"title": "No Money",
"length": 185
}
]
}, {
"title": "Kolony",
"artist": "Steve Aoki",
"year_released": 2017,
"songs": [{
"title": "Lit",
"length": 150
},
{
"title": "Without you",
"length": 207
},
{
"title": "Been Ballin",
"length": 180
},
{
"title": "How Else",
"length": 152
}
]
}]

关于javascript - 我正在尝试使用 JSON 存储音乐专辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46697129/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com