我正在使用Mongo(使用mongoose解决方案)开发node.js应用程序,以使用Quickbooks Online API中的数据创建自定义报告解决方案。 这是工作流程:
JSON回复
{ Header:
{ Time: '2014-09-09T10:55:01-07:00',
ReportName: 'VendorBalanceDetail',
StartPeriod: '2014-10-01',
EndPeriod: '2014-10-09',
Currency: 'USD',
Option: [ { Name: 'report_date', Value: '2014-10-09' } ] },
Columns:
{ Column:
[ { ColTitle: 'Date', ColType: 'tx_date' },
{ ColTitle: 'Transaction Type', ColType: 'txn_type' },
{ ColTitle: 'Num', ColType: 'doc_num' },
{ ColTitle: 'Due Date', ColType: 'due_date' },
{ ColTitle: 'Amount', ColType: 'subt_neg_amount' },
{ ColTitle: 'Open Balance', ColType: 'subt_neg_open_bal' },
{ ColTitle: 'Balance', ColType: 'rbal_neg_open_bal' } ] },
Rows:
{ Row:
[ { Header:
{ ColData:
[ { value: 'GS & CO' },
{ value: '' },
{ value: '' },
{ value: '' },
{ value: '' },
{ value: '' },
{ value: '' } ] },
Rows:
{ Row:
[ { ColData:
[ { value: '01/31/2014' },
{ value: 'Bill' },
{ value: 'FY/2013-01/2014' },
{ value: '01/31/2014' },
{ value: '9963.14' },
{ value: '9963.14' },
{ value: '9963.14' } ],
type: 'Data' },
{ ColData:
[ { value: '02/28/2014' },
{ value: 'Bill' },
{ value: '02/2014' },
{ value: '02/28/2014' },
{ value: '6378.14' },
{ value: '6378.14' },
{ value: '16341.28' } ],
type: 'Data' },
{ ColData:
[ { value: '03/31/2014' },
{ value: 'Bill' },
{ value: '03/2014' },
{ value: '03/31/2014' },
{ value: '2556.0' },
{ value: '2556.0' },
{ value: '18897.28' } ],
type: 'Data' },
{ ColData:
[ { value: '04/30/2014' },
{ value: 'Bill' },
{ value: '04/2014' },
{ value: '04/30/2014' },
{ value: '5221.0' },
{ value: '5221.0' },
{ value: '24118.28' } ],
type: 'Data' },
{ ColData:
[ { value: '05/31/2014' },
{ value: 'Bill' },
{ value: '05/2014' },
{ value: '05/31/2014' },
{ value: '2735.96' },
{ value: '2735.96' },
{ value: '26854.24' } ],
type: 'Data' },
{ ColData:
[ { value: '06/30/2014' },
{ value: 'Bill' },
{ value: '06/2014' },
{ value: '06/30/2014' },
{ value: '658.0' },
{ value: '658.0' },
{ value: '27512.24' } ],
type: 'Data' },
{ ColData:
[ { value: '07/31/2014' },
{ value: 'Bill' },
{ value: '6-17 to 7-31' },
{ value: '07/31/2014' },
{ value: '162.32' },
{ value: '162.32' },
{ value: '27674.56' } ],
type: 'Data' } ] },
Summary:
{ ColData:
[ { value: 'Total for GS & CO' },
{ value: '' },
{ value: '' },
{ value: '' },
{ value: '27674.56' },
{ value: '27674.56' },
{ value: '' } ] },
type: 'Section' }
我的模特:
module.exports = mongoose.model('vbDetail', {
company_name: String,
row:{
date: Date,
transaction_type: String,
transaction_num: String,
due_date: Date,
amount: Number,
open_balance: Number,
balance: Number,
identifier: String,
processing_date: Date,
processing_amount :Date,
notes: String
}
})
除了JSON响应之外,最后三个字段是我想要存储的自定义字段。
我的问题是如何从响应中获取JSON并对其进行解析以使其“坚持”#34;我的模特?