Home > front end >  How to overcome WARNING: Resulting JSON is truncated as serialization has exceeded the set depth of
How to overcome WARNING: Resulting JSON is truncated as serialization has exceeded the set depth of

Time:01-18

Have provided my code and json format below. I'm using powershell runbook to retrieve the values from this json. But facing error. Can anyone please help me out regarding the same ?

My json :

{"hunting": [
  {
    "displayName":"New Changes made to AWS IAM policy", 
    "description":"test",
    "query":"SecurityEvent | where EventID == \"4687\" | where CommandLine contains \"-noni -ep bypass $\"",
    "tactics":["Persistence","LateralMovement","Collection"]
  },{
    "displayName":"New Consent to Application discovery",
    "description":"test",
    "query":"SecurityEvent | where EventID == \"4688\" | where CommandLine contains \"-noni -ep bypass $\"",
    "tactics":["Persistence","LateralMovement"]
   }
]}

My code:

Get-AzStorageBlobContent -Destination $outPath -Container $containerName -Blob $huntingQueryFileName  -Context $storageContext -Force

$newHuntingRules = Get-Content -Path "$outPath\$huntingQueryFileName" -Raw | ConvertFrom-Json  

Facing the below error:

WARNING: Resulting JSON is truncated as serialization has exceeded the set depth of 2

CodePudding user response:

I executed below script in my environment and was able to successfully retrieve the expected content (from json format).

$path = "C:\temp"
$context = New-AzStorageContext -StorageAccountName "jahnavistorage" -StorageAccountKey "<storageaccountkey>=="
Get-AzStorageBlobContent -Container "<containerName>" -Blob "myjson.json" -Destination $path -context $context
Get-ChildItem -path $path
Get-Content -Raw $path\myjson.json | ConvertFrom-Json

Output:

enter image description here

enter image description here

  • Related