【发布时间】:2017-12-05 01:27:55
【问题描述】:
我正在尝试通过在 wordpress 的 ionWordpress(离子框架插件)中使用 JSON 来获取数据。
我正在使用 JSON API。这是来自我的 JSON 的数据。
{
"status": "ok",
"count": 6,
"count_total": 45,
"pages": 8,
"posts": [
{
"id": 1874,
"type": "event",
"slug": "stesets",
"url": "http://www.web.com/page",
"status": "publish",
"title": "setst",
"title_plain": "tests",
"content": "testsetstst",
"excerpt": "testsetststtes",
"date": "2017-11-27 17:20:17",
"modified": "2017-11-27 17:20:17",
"categories": [],
"tags": [],
"author": {
"id": 1,
"slug": "test",
"name": "test",
"first_name": "",
"last_name": "",
"nickname": "test",
"url": "",
"description": ""
},
"comments": [],
"attachments": [],
"comment_count": 0,
"comment_status": "closed",
"thumbnail": "http://www.website.com/wp-content/uploads/2017/11/image.jpg",
我的问题是当我尝试获取数据时,它也包含 []。例如。
{{post.thumbnail}}
这将显示 ["http://www.website.com/wp-content/uploads/2017/11/image.jpg"]
但我只想要链接本身没有 [" "]
我该怎么做?
【问题讨论】:
-
已经尝试 json_decode 了吗?
-
您在哪里使用
{{post.thumbnail}},请您也发布该代码吗? -
你为什么不试试 {{post.thumbnail[0]}}
-
我意识到它也发生在 custom_fields 上。是不是因为我需要对这些进行查询。如果是这样,我会怎么做?我需要更新 wordpress 中的 JSON API 插件吗? {{ post.title }}、{{ post.slug }} 等基本元素可以正常工作。
标签: php angularjs json cordova ionic-framework