今天我和Filemaker讨论了如何在不知道密钥的情况下从json结果中获取第一个元素。
来自API调用的示例$ json结果
{
"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字符串中获取第一个元素?
答案 0 :(得分:2)
尝试使用根元素:
JSONListKeys ($ json;“”)
结果: 26298070 获得root后,您就可以获得子密钥。
答案 1 :(得分:0)
我记得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模式变得容易。