我引用了这个问题的答案,
我的样本数据
$personData = @'
{
"persons": [{
"johndoe": [{
"id": "4334234 <>",
"family_adress": {
"mother": "address of family",
"father": "",
"brother": "address of family"
},
"childiren": {
"first": 1024,
"second":128
},
"years_activity": {
"2021": [ "sample entry-1", "sample entry-2" ],
"2022": [ "sample entry-1", "sample entry-2" ]
}
}],
"johndoe2": [{
"id": "4334234 <>",
"family_adress": {
"mother": "address of family...",
"father": "",
"brother": "...address of family"
},
"childiren": {
"first": 25,
"second": 12
},
"years_activity": {
"2021": [ "sample entry-4", "sample entry-r" ],
"2022": [ "sample entry-5", "sample entry-s" ]
}
}]
}]
}
'@ | ConvertFrom-Json
我的输出:
NamePath Value
-------- -----
persons[0].johndoe[0].id 4334234 <>
persons[0].johndoe[0].family_adress.mother address of family
persons[0].johndoe[0].family_adress.father
persons[0].johndoe[0].family_adress.brother address of family
persons[0].johndoe[0].childiren.first 1024
persons[0].johndoe[0].childiren.second 128
persons[0].johndoe[0].years_activity.2021[0] sample entry-1
persons[0].johndoe[0].years_activity.2021[1] sample entry-2
persons[0].johndoe[0].years_activity.2022[0] sample entry-1
persons[0].johndoe[0].years_activity.2022[1] sample entry-2
persons[0].johndoe2[0].id 4334234 <>
persons[0].johndoe2[0].family_adress.mother address of family...
persons[0].johndoe2[0].family_adress.father
persons[0].johndoe2[0].family_adress.brother ...address of family
persons[0].johndoe2[0].childiren.first 25
persons[0].johndoe2[0].childiren.second 12
persons[0].johndoe2[0].years_activity.2021[0] sample entry-4
persons[0].johndoe2[0].years_activity.2021[1] sample entry-r
persons[0].johndoe2[0].years_activity.2022[0] sample entry-5
persons[0].johndoe2[0].years_activity.2022[1] sample entry-s
- 我想用CSV访问此NamePaths。
**标题:**id family_address children years_activitys //**我的行:**JohnDoe,JohnDoe 2 - 在CSV之后,我想访问打印所有属性x,
foreach (person in CSV) {
id:
family_address:
childrens:
years_activitys: (if header equal to SubArray also print them separately)
}
- 我也可以用结构化的格式访问这些值,比如
foreach(activities in person.$username.years_activitys){ key:值}
我正在努力做这样的事情,提前感谢您的帮助。
1条答案
按热度按时间jpfvwuh41#
试着跟随。我用你的输入创建了一个表,这样我就可以测试。我把活动按日期分开列,而不是另起一行