我正在尝试为我正在完成的 javascript 教程设置 JSON 格式的示例数据集。
数据对象在 javascript 中如下所示:
app.Book = Backbone.Model.extend({
defaults: {
coverImage: 'img/getfile.jpg',
title: 'No title',
author: 'Unknown',
releaseDate: 'Unknown',
keywords: 'None'
}
});
这是我在 .net 服务器中创建的数据 JSON 示例,我将检索它以填充上面的对象。
Private Shared Books As String =
<test>
[
{
"Book" : [
"coverImage" : "",
"title" : "Enders Game",
"author" : "Orson Scott Card",
"releaseDate" : "1/1/1965",
"keywords: "science fiction"
]
}
],
[
{
"Book" : [
"coverImage" : "",
"title" : "Parable of the Sower",
"author" : "Octavia E. Butler",
"releaseDate" : "1/1/2000",
"keywords: "science fiction"
]
}
],
[
{
"Book" : [
"coverImage" : "",
"title" : "Fahrenheit 451: A Novel",
"author" : "Ray Bradbury",
"releaseDate" : "1/1/1950",
"keywords: "science fiction"
]
}
]
</test>.Value.Trim()
但是,每当我尝试使用 GET 检索数据时,我的控制台中都会出现“对象未采用指定格式”错误。
所以我的问题是,我的 JSON 数据格式是否与 javascript 对象匹配?
谢谢!