不能从下面的json得到标题
Cant get the title from the following json
我有这个代码到我的应用程序,返回一些json格式的工作提要:
我的代码如下:
JobFeed.find().sort('-created').exec(function (err, feeds) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
_.forEach(feeds, function (row, key) {
console.log(row.data.title); // showing undefined
});
res.jsonp(feeds);
}
});
json如下所示:
{ data:
{ isSaved: null,
client:
{ lastContractTitle: null,
feedbackText: '4.78 Stars, based on 13 feedbacks',
paymentVerificationStatus: 1,
lastContractPlatform: null,
totalFeedback: 4.7819242373,
location: [Object],
lastContractRid: 0,
edcUserId: 3728985,
totalReviews: 13,
companyRid: 0,
spentTier: '$7,500+',
companyName: null },
amount: { amount: 0, currencyCode: 'USD' },
createdOn: '2016-10-13T06:30:54+00:00',
skills: [ [Object], [Object], [Object], [Object] ],
enterpriseJob: false,
ciphertext: '~01026b31d972ed826b',
proposalsTier: null,
description: 'Hello! We''re currently searching for a developer with',
category2: 'Web, Mobile & Software Dev',
type: 2,
tierText: 'Intermediate ($$)',
relevance:
{ hoursInactive: 0,
id: 208660674,
publishTime: '1476340265000',
recommendedEffectiveCandidates: 2,
effectiveCandidates: 3,
uniqueImpressions: 0 },
isApplied: null,
engagement: '30+ hrs/week',
recno: 208660674,
title: 'Server-side and Client-side Game Developer for Indie MMO',
freelancersToHire: 0,
maxAmount: { amount: 0, currencyCode: 'USD' },
duration: 'More than 6 months',
subcategory2: 'Game Development',
sticky: false,
stickyLabel: '',
feedback: null },
id: 57ffcdbf717ca50cf0b4cbc1 }
{ data:
{ isSaved: null,
client:
{ lastContractTitle: null,
feedbackText: 'No feedback yet',
paymentVerificationStatus: 1,
lastContractPlatform: null,
totalFeedback: 0,
location: [Object],
lastContractRid: 0,
edcUserId: 0,
totalReviews: 0,
companyRid: 0,
spentTier: '$100+',
companyName: null },
amount: { amount: 0, currencyCode: 'USD' },
createdOn: '2016-10-13T06:30:51+00:00',
skills: [ [Object], [Object], [Object] ],
enterpriseJob: false,
ciphertext: '~01c59efb9135ed91d0',
proposalsTier: null,
description: 'Hello! We''re currently searching for a developer with',
category2: 'Web, Mobile & Software Dev',
type: 2,
tierText: 'Entry Level ($)',
relevance:
{ hoursInactive: 0,
id: 208660673,
publishTime: '1476340266000',
recommendedEffectiveCandidates: 18,
effectiveCandidates: 74,
uniqueImpressions: 0 },
isApplied: null,
engagement: 'Less than 10 hrs/week',
recno: 208660673,
title: 'Wordpress & Stripe developer',
freelancersToHire: 0,
maxAmount: { amount: 0, currencyCode: 'USD' },
duration: 'More than 6 months',
subcategory2: 'Web Development',
sticky: false,
stickyLabel: '',
feedback: null },
id: 57ffcdbf717ca50cf0b4cbc2 }
{ data:
{ isSaved: null,
client:
{ lastContractTitle: null,
feedbackText: 'No feedback yet',
paymentVerificationStatus: 5,
lastContractPlatform: null,
totalFeedback: 0,
location: [Object],
lastContractRid: 0,
edcUserId: 0,
totalReviews: 0,
companyRid: 0,
spentTier: 'Less than $100',
companyName: null },
amount: { amount: 2000, currencyCode: 'USD' },
createdOn: '2016-10-13T06:30:18+00:00',
skills: [ [Object], [Object] ],
enterpriseJob: false,
ciphertext: '~0101449f91585e8e16',
proposalsTier: null,
description: 'I need a Christmas card app before 15th Dec.n',
category2: 'Web, Mobile & Software Dev',
type: 1,
tierText: 'Intermediate ($$)',
relevance:
{ hoursInactive: 0,
id: 208660669,
publishTime: '1476340233000',
recommendedEffectiveCandidates: 7,
effectiveCandidates: 52,
uniqueImpressions: 0 },
isApplied: null,
engagement: null,
recno: 208660669,
title: 'Christmas Card iPhone App',
freelancersToHire: 0,
maxAmount: { amount: 0, currencyCode: 'USD' },
duration: null,
subcategory2: 'Mobile Development',
sticky: false,
stickyLabel: '',
feedback: null },
id: 57ffcdbf717ca50cf0b4cbc3 }
{ data:
{ isSaved: null,
client:
{ lastContractTitle: null,
feedbackText: '4.88 Stars, based on 102 feedbacks',
paymentVerificationStatus: 1,
lastContractPlatform: null,
totalFeedback: 4.8843944128,
location: [Object],
lastContractRid: 0,
edcUserId: 0,
totalReviews: 102,
companyRid: 0,
spentTier: '$25,000+',
companyName: null },
amount: { amount: 100, currencyCode: 'USD' },
createdOn: '2016-10-13T06:30:00+00:00',
skills:
[ [Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object] ],
enterpriseJob: false,
ciphertext: '~01a04eab3b05372652',
proposalsTier: null,
description: 'Hello! We''re currently searching for a developer with',
category2: 'Writing',
type: 1,
tierText: 'Entry Level ($)',
relevance:
{ hoursInactive: 0,
id: 208660668,
publishTime: '1476340202000',
recommendedEffectiveCandidates: 2,
effectiveCandidates: 6,
uniqueImpressions: 0 },
isApplied: null,
engagement: null,
recno: 208660668,
title: 'Filipino Blog/Content Writers For a Filipino Site (Using WordPress)',
freelancersToHire: 3,
maxAmount: { amount: 0, currencyCode: 'USD' },
duration: null,
subcategory2: 'Article & Blog Writing',
sticky: false,
stickyLabel: '',
feedback: null },
id: 57ffcdbf717ca50cf0b4cbc4 }
我拥有的foreach
似乎遍历每个项目,但我无法获得每个项目的标题。任何帮助吗?
我真的不知道你在做什么,但这样的东西应该工作,如果数据确实是你有你的评论:
feeds.forEach(function(feed){
console.log(feed.data.title);
});
如果想要更快的性能,请使用常规的for循环。我在自己的项目中对此进行了测试。
相关文章:
- jQuery匹配JSON对象的部分文本
- 在循环中分配json值时,值被覆盖
- 无标题Javascript JSON数组->CSV导出
- 如何在javascript w Ajax和JSON中使用v3 URL API获取Youtube视频标题
- 在underscore.js中使用相同的json分别构建表标题和数据的最佳方法
- 返回标题JSON的所有值
- 获取 JSON 对象标题
- 不能从下面的json得到标题
- 添加到购物车按钮不工作-拒绝获得不安全的标题"X-JSON"
- 返回最近的特征(json)多边形的标题使用传单JS
- 将JSON对象数组转换为可用于为行制作标题的变量
- 如何获得JSON标题
- 谷歌地图pin标题从json数组
- 如何使用JSON列出带有链接的维基百科页面标题
- 定义我的导航的JSON有标题类型和类别类型;d希望转换为Javascript中的嵌套UL LI元素
- 如何访问Json中的元素标题
- 以 json 为单位的日期列每周标题
- 从JQuery中没有标题的对象访问JSON对象
- 如何在angularjs中从JSON数组动态生成列标题和表值
- iccast json-status.xls,无效json答案与空白歌曲标题