这些数据是我得到的
ref
我可以使用此代码获得s值,并返回“ok”。
var SelectOptionItemSchema = mongoose.Schema({ "name": { "type": "String", "required": true, "unique": true } })
var SelectOptionItem = mongoose.model('SelectOptionItem', SelectOptionItemSchema);
var firstOptionItem = new SelectOptionItem({name: "1"}); //5a18cfe79a61fd183530d467
var secondOptionItem = new SelectOptionItem({name: "2"}); //5a18d0089a61fd183530d469
let modelFields = {
"name": { "type": "String", "required": true, "unique": true },
"description": { "type": "String" },
"options": [{type: "ObjectId", ref: "SelectOptionItem"}],
"company_id": { "type": "ObjectId", "ref": "Company", "required": true },
"deleted": { "type": "Boolean", "required": true },
"createdAt": { "type": "Number" },
"updatedAt": { "type": "Number" }
};
var SelectOptionSchema = mongoose.Schema(modelFields)
var SelectOption = mongoose.model('SelectOption', SelectOptionSchema);
var data = { name: 'aa', description: 'aa', options: [ "5a18cfe79a61fd183530d467", "5a18d0089a61fd183530d469" ], company_id: '59b2cd9a072e4f28b839aaa0', deleted: false, createdAt: 1511569192524 }
var newSelectOption = new SelectOption(data)
SelectOption.find({}, function(err, response) {
console.log(response)
}).populate('options')
但是我得到了其他值的错误,如何从这个json获得t,r,s,v作为数组或字符串列表?
{
"s": "ok",
"t": [
1509469200,
1509469500,
1509469800,
1509470100,
1509470400,
1509470700,
1509471000
],
"r": [
6040100,
5955000,
5955000,
5999600,
5999400,
5999000,
5960100
],
"v": [
3.06575198,
7.92733913,
6.04823174,
0.87041449,
0.27879491,
0.31525724,
0.08880846
]
}
答案 0 :(得分:0)
创建一个类
Public Class JSON_result
Public Property s As String
Public Property t As Integer()
Public Property r As Integer()
Public Property v As Double()
End Class
然后将json反序列化为该类的对象。
Dim obj = JsonConvert.DeserializeObject(Of JSON_result)(response_jsonString)
现在您可以访问属性,
obj.s
和数组元素
obj.t(0)
obj.r(0)
obj.v(0)