javascript – RESTful Backbone应用程序中JSON的预期结构是什么?
作者:互联网
使用Backbone / Marionette开发专有的CRM应用程序,我想知道,Backbone对JSON的期望是什么结构?这就是我目前正在使用的内容,但我可以将其更改为最适合的内容. (如果可能的话,我想避免设置自定义解析功能.)
{
"rowCount":"1",
"records":[
{
"objectName":"",
"User_UserID":"",
"User_EmailAddress":"",
"User_Password":"",
"User_EncPassword":"",
"User_Premium":"",
"User_FirstName":"",
"User_LastName":"",
"User_Honorific":"",
"User_Title":"",
"User_Nickname":"",
"User_ParentCompany":"",
"User_Company":"",
"User_Publication":"",
"User_Website":"",
"User_ShipAddress1":"",
"User_ShipAddress2":"",
"User_ShipAddress3":"",
"User_ShipCity":"",
"User_ShipState":"",
"User_ShipCountry":"",
"User_ShipZip":"",
"User_BillCompany":"",
"User_BillFirstName":"",
"User_BillLastName":"",
"User_BillAddress1":"",
"User_BillAddress2":"",
"User_BillAddress3":"",
"User_BillCity":"",
"User_BillState":"",
"User_BillCountry":"",
"User_BillZip":"",
"User_PhoneNo":"",
"User_FaxNo":"",
"User_HomeNo":"",
"User_MobileNo":"",
"User_OtherNo1":"",
"User_OtherNo2":"",
"User_IChat_Aim":"",
"User_IChat_Gchat":"",
"User_IChat_MSN":"",
"User_IChat_Etc":"",
"User_CreateIPAddress":"",
"User_CreateDate":"",
"User_ViewDate":"",
"User_ModifyDate":"",
"User_ConvertDate":"",
"User_LastMailedDate":"",
"User_LastACSCheckDate":"",
"User_CCType":"",
"User_CCNo":"",
"User_LoggendBy":"",
"User_ContactVia":"",
"User_Source":"",
"User_RelatedAssistant":"",
"User_Specialties":"",
"User_JobType":"",
"User_CompanyType":"",
"User_TaxID":"",
"User_Notes":"",
"User_TermsExtended":"",
"User_AcsAdvice":"",
"User_MailList":"",
"User_EMailList":"",
"User_PressList":"",
"User_CustomList":"",
"User_HolidayList":"",
"User_VIPList":"",
"User_MarketingBlacklist":"",
"User_SalesBlacklist":"",
"User_IsCustomer":"",
"User_Answer1":"",
"User_Answer2":"",
"User_Answer3":"",
"User_Answer4":"",
"User_Answer5":"",
"User_NewPassword":"",
"User_OldPassword":"",
"User_FMUserID":"",
"User_FMUser":"",
"User_BetaUser":"",
"User_ShowFeatures":"",
"User_TermsVersion":"",
"User_TOSVersion":"",
"User_TOSDate":"",
"User_TOSIP":"",
"User_TOSLastVersion":"",
"User_TOSLastDate":"",
"User_TOSLastIP":"",
"User_LoginDate":"",
"User_LoginIPAddress":"",
"User_FMName":"",
"User_NameSuffix":"",
"User_FaxLabel":"",
"User_OtherNo1Label":"",
"User_OtherNo2Label":"",
"User_EmailAddressAlternate":"",
"User_LoggedBy":"",
"User_IsObsolete":"",
"User_AddressSame":"",
"User_UserDate":"",
"User_DeferredPay":"",
"User_TaxExempt":"",
"User_TaxExemptID":"",
"User_Saved":"",
"User_Status":"",
"User_Migrated":""
}
]
}
解决方法:
本地,Backbone.Model需要一个简单的字符串字典:
{
"name": "Bob",
"address": "12345 Simple St",
...
}
…和Backbone.Collection期望一组简单的字符串字典:
[{
"name": "Bob",
"address": "12345 Simple St",
...
},{
"name": "Al",
"address": "12347 Main St",
...
},
...
]
标签:javascript,json,backbone-js,marionette 来源: https://codeday.me/bug/20190825/1719652.html