【发布时间】:2022-01-18 08:45:32
【问题描述】:
我有一个 Rest Api,我必须从中检索位于 links->href 中的集群之后的值,即“000000000000000000000000000000000”。那么如何获得该特定值?
[{
"analysisUnits": [
{
"links": [
{
"href": "http://127.0.0.1/api/v1/clusters/00000000000000000000000000000000/aus/e6ec00e6da1c46c2a1060b3b8ae54765",
"rel": "self"
}
],
"name": "OZL6106W",
"uuid": "e6ec00e6da1c46c2a1060b3b8ae54765"
}
],
"links": [
{
"href": "http://127.0.0.1/api/v1/clusters/00000000000000000000000000000000",
"rel": "self"
}
],
"name": "MTS Recording Cluster",
"recordingUnits": [],
"uuid": "00000000000000000000000000000000"}]
【问题讨论】:
-
const link = data[0].links[0].href.split('/');console.log(link[link.length - 1]) -
这里的数据[0]是什么?
-
将 JSON 分配给数据变量
-
将在答案中发布
-
不要忘记投票和标记答案。如果任何解决方案都有效