在API响应中找到单引号字符串文字

时间:2018-07-03 18:55:02

标签: json swift

Xcode的一些更新,我正在开发我的应用程序,该应用程序将提供牛津词典中的定义,而通往这些定义的途径是

 if let def = json['results'][0]['lexicalEntries'][0]['entries'][0]['senses'][0]['definitions'].string 
{
print(def)
}

现在Xcode说我应该将'替换为,但是如果这样做,我的结果将为空。如何绕过还是有另一种方法可以创建定义的途径?

这是结果的一个示例(这不是完整的结果,我需要达到“定义”

{
  "results" : [
    {
      "language" : "en",
      "id" : "ace",
      "type" : "headword",
      "lexicalEntries" : [
        {
          "language" : "en",
          "entries" : [
            {
              "etymologies" : [
                "Middle English (denoting the ‘one’ on dice): via Old French from Latin as ‘unity, a unit’"
              ],
              "grammaticalFeatures" : [
                {
                  "type" : "Number",
                  "text" : "Singular"
                }
              ],
              "homographNumber" : "100",
              "senses" : [
                {
                  "definitions" : [
                    "a playing card with a single spot on it, ranked as the highest card in its suit in most card games"

如果只走一步json["results"],它已经失败了,而我的结果为空。

0 个答案:

没有答案