【问题标题】:Ionic Data Parse using JSON API Issue使用 JSON API 问题的离子数据解析
【发布时间】: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


【解决方案1】:

我用过:

{{post.thumbnail[0]}}

正如 Diluk Angelo 在 cmets 中提到的那样。

【讨论】:

    猜你喜欢
    • 2019-01-30
    • 1970-01-01
    • 2018-04-15
    • 1970-01-01
    • 2020-12-24
    • 2019-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多