Sorry to intrude on this solution.
But could it be used to count how many times a key is found in JSON?
I have an order file which consists of different orderlines. Some is for production. Others are just for invoicing.
So I would like a count of every time "Buchs_Nr" is pressent. So in the case of the the code below the count should be 2.
Code: Select all
{
"Ordre": {
"GUID": "A842AA5F-F8F9-4BE3-B9BD-2FE10FB57F58",
"OrdreNr": "999995",
"OrdreDato": "2023-12-07",
"Send_Ordrebekræftelse": true,
"Tid_HP": 25.0,
"Tid_Efterbehandling": 35.0,
"Tid_Opskæring": 30.0
},
"Linjer": [
{
"GUID": "CD871AF3-12B2-4843-BF75-D5B63E6D9569",
"Produkt": [
{
"Buchs_Nr": "999991",
"Materiale": "MC Primecoat OPQ BL S2000 N-BG40",
"Stans": [
{
"StanseNr": "STA0077",
"StanseType": "Firkant afr. 2 mm"
}
],
"Foil": null,
"Farve": "Sort + Blank TTR LakSort TTR Lak"
}
],
"Antal": 10000.0,
"Enhed": "stk.",
"Enhedspris": 0.5,
"PrisEnhed": 1
},
{
"GUID": "C4663089-0E11-4853-87B1-93308A539A10",
"Produkt": [
{
"Buchs_Nr": "888881",
"Materiale": "MC Primecoat OPQ BL S2000 N-BG40",
"Stans": [
{
"StanseNr": "STA0077",
"StanseType": "Firkant afr. 2 mm"
}
],
"Foil": null,
"Farve": "Sort + Blank TTR LakSort TTR Lak"
}
],
"Antal": 10000.0,
"Enhed": "stk.",
"Enhedspris": 0.5,
"PrisEnhed": 1
},
{
"GUID": "05C4CB0B-0C0E-4AC9-9E2B-2947288949B3",
"Produkt": null,
"Beskrivelse": "Andel af stans"
},
{
"GUID": "195708AF-C90E-4BC0-8C0E-BE99A2787610",
"Produkt": null,
"Beskrivelse": "Tilretning af filer"
}
]
}
I have a solution using the command line tool "jq" running with the "Run Command" program.
Code: Select all
"C:\ProgramData\chocolatey\lib\jq\tools\jq.exe" "[.. | .Buchs_Nr? | select(.!=null)] | length" "%%InputFilePath%%"
But as Magnus I would like a more native solution.