I have a JSON file that looks like this:
$jsondata = '{
"ips": {
"10.20.30.40": [
{
"rhost": "DNS Name1.",
"rdata": [
"10.20.30.40"
],
"rrtype": "A (1)",
"ttl": 86400,
"geo": null,
"source": "DNSProvider1"
}
],
"40.50.60.70": [
{
"rhost": "DNS Name2.",
"rdata": [
"40.50.60.70"
],
"rrtype": "A (1)",
"ttl": 86400,
"geo": null,
"source": "DNSProvider1"
}
]
}
}'
I want to get all the TTLs (for example) of every IP address in the list.
I converted this JSON to Powershell PSCustomObject:
$obj = $jsondata | convertFrom-Json
and now I want to get all the TTLs, I tried to get the list of the IPs (as a start):
foreach ($ip in $a.ips) {write-host $ip }
and I'm not getting strings as a result, that's why I (probably) can't go inside and get the TTLs.
So my question: how can I get all the IPs as strings?
I believe that once I'll get an answer for that, I'll understand how I can go over all the IPs in the list.
Thanks!
$objand$a. Is that a typo? Can you show what results you're getting?