我有contacts.json文件:
end=$((SECONDS+86400))

所以我想在Julia的emergencyContacts数组中访问Name键。我试过这个:
{
"emergencyContacts": [
{
"name": "Jane Doe",
"phone": "888-555-1212",
"relationship": "spouse"
},
{
"name": "Justin Doe",
"phone": "877-123-1212",
"relationship": "parent"
}
]
}

答案 0 :(得分:2)
这是一个指定不清的问题:
据推测,您正在寻找
julia> first_names = String[]
0-element Array{String,1}
julia> for contact in dict["emergencyContacts"]
push!(first_names, split(contact["name"]," ")[1])
end
julia> first_names
2-element Array{String,1}:
"Jane"
"Justin"
可以使用dict["emergencyContacts"][n]["name"]
为数组元素提取名为“name”的“嵌套”键,其中n
是数组索引。