Wordpress API uglify/JSON 引用问题
Wordpress API uglify/JSON reference issue
我正在尝试引用 API 中的某些项目,但 uglify 甚至我的文本编辑器都在与我作对。例如:
post._embedded.author[0].avatar_urls.96
导致 uglify 抛出错误(可能是因为数字)。这是另一个例子:
post._embeded.wp:featuredmedia[0].media_details.sizes.full.source_url
也给我带来了问题(因为冒号)。
我该如何克服这个问题?这是我要构建的完整对象:
var postObject = {
id: post.id,
link: post.link,
title: post.title.rendered,
author: post._embedded.author[0].name,
authorImage: post._embedded.author[0].avatar_urls .96,
excerpt: post.excerpt.rendered,
categories: post.categories, //add array of categories[]
featuredImage: post._embedded.wp:featuredmedia[0].media_details.sizes.full.source_url
};
我把这个整理好了!
post._embedded['wp:featuredmedia'][0].media_details.sizes.full.source_url
我不知道括号符号!
我正在尝试引用 API 中的某些项目,但 uglify 甚至我的文本编辑器都在与我作对。例如:
post._embedded.author[0].avatar_urls.96
导致 uglify 抛出错误(可能是因为数字)。这是另一个例子:
post._embeded.wp:featuredmedia[0].media_details.sizes.full.source_url
也给我带来了问题(因为冒号)。
我该如何克服这个问题?这是我要构建的完整对象:
var postObject = {
id: post.id,
link: post.link,
title: post.title.rendered,
author: post._embedded.author[0].name,
authorImage: post._embedded.author[0].avatar_urls .96,
excerpt: post.excerpt.rendered,
categories: post.categories, //add array of categories[]
featuredImage: post._embedded.wp:featuredmedia[0].media_details.sizes.full.source_url
};
我把这个整理好了!
post._embedded['wp:featuredmedia'][0].media_details.sizes.full.source_url
我不知道括号符号!