I have a json file and I want to pass the value of a field to a variable the json file has the following structure
{
"actions": {
"send_dian": false,
"send_email": false
},
"invoice": {
"number": "990001344",
"invoice_type_code": "FACTURA_VENTA",
"numbering": {
"resolution_number": "18760000001",
"prefix": "MSTL",
"flexible": true
},
"customer": {
"email": "TOROFABIAN@GMAIL.COM",
"phone": "3136490333",
"company_name": "LUIS FABIAN TORO GUTIERREZ"
}
}
}
and I want to pass the value of the "number" field to a variable like this:
$archivo = "archivo1.json"
$body = Get-Content $archivo
$numerofolio1 = $body.psobject.properties["number"].value
Write-Host "numero de folio:" $numerofolio1
$numerofolio1
$numerofolio2 = $body.psobject.properties["invoice.number"].value
Write-Host "numero de folio:" $numerofolio2
$numerofolio2
but neither of the two ways sends me the value of "number".
how should I do it? Thanks