代码之家  ›  专栏  ›  技术社区  ›  Keith John Hutchison

如何在不知道filemaker 16或17中元素的名称的情况下从json字符串中获取第一个元素?

  •  0
  • Keith John Hutchison  · 技术社区  · 8 年前

    今天我和filemaker有个问题,就是如何在不知道键的情况下从json结果中获取第一个元素。

    示例$json是api调用的结果

    {
        "26298070": {
            "task_id": "26298070",
            "parent_id": "0",
            "name": "DEPOT-0045 Research ODBC Model Extraction via Django To cut down on development time from Filemaker to Postgres",
            "external_task_id": "32c8fd51-2066-42b9-b88b-8a2275fafc3f",
            "external_parent_id": "64e7c829-d88e-48ae-9ba4-bb7a3871a7ce",
            "level": "1",
            "add_date": "2018-06-04 21:45:16",
            "archived": "0",
            "color": "#34C644",
            "tags": "DEPOT-0045",
            "budgeted": "1",
            "checked_date": null,
            "root_group_id": "91456",
            "assigned_to": null,
            "assigned_by": null,
            "due_date": null,
            "note": "",
            "context": null,
            "folder": null,
            "repeat": null,
            "billable": "0",
            "budget_unit": "hours",
            "public_hash": null,
            "modify_time": null
        }
    }
    

    我尝试了jsongetelement($json,“”),得到了原始的json。 我尝试了jsongetelement($json,“.”),得到了原始的json。 我试过jsongetelement($json,1),但什么也没有得到。

    如何在不知道filemaker 16或17中元素的名称的情况下从json字符串中获取第一个元素?

    2 回复  |  直到 8 年前
        1
  •  2
  •   user9894513    8 年前

    对根元素尝试此操作:

    JSONListKEY ($json;“”)

    结果: 二千六百二十九万八千零七十 一旦你得到根,你就可以得到子密钥。

        2
  •  0
  •   Keith John Hutchison    8 年前

    我记得filemaker有一个从文本中提取单词的功能,所以我想如果我提取第一个单词作为关键字,我会看到发生了什么。

    我试过

    JSONGetElement ( $json ; MiddleWords ( $json,1,1 ) )
    

    得到了我想要的结果。

    {
        "add_date": "2018-06-04 21:45:16",
        "archived": "0",
        "assigned_by": null,
        "assigned_to": null,
        "billable": "0",
        "budget_unit": "hours",
        "budgeted": "1",
        "checked_date": null,
        "color": "#34C644",
        "context": null,
        "due_date": null,
        "external_parent_id": "64e7c829-d88e-48ae-9ba4-bb7a3871a7ce",
        "external_task_id": "32c8fd51-2066-42b9-b88b-8a2275fafc3f",
        "folder": null,
        "level": "1",
        "modify_time": null,
        "name": "DEPOT-0045 Research ODBC Model Extraction via Django To cut down on development time from Filemaker to Postgres",
        "note": "",
        "parent_id": "0",
        "public_hash": null,
        "repeat": null,
        "root_group_id": "91456",
        "tags": "DEPOT-0045",
        "task_id": "26298070"
    }
    

    这使得解析使用属性作为键的简单json模式变得很容易。