Extract data from json with specific condition

Hi All,

I have a json data, which looks like below -

“Conditions”: [

{

  "ConditionNumber": "E51248069",

  "SheetNumber": "0016",

  "Attribute": "02032",

  "CheckType": "NEL",

  "CheckLevel": "SET",

  "Version": "M",

  "VisibilityScope": "S"

},

{

  "ConditionNumber": "E51248071",

  "SheetNumber": "0016",

  "Attribute": "02032",

  "CheckType": "NEL",

  "CheckLevel": "SET",

  "Version": "M",

  "VisibilityScope": "S"

},

{

  "ConditionNumber": "E51313386",

  "SheetNumber": "0016",

  "Attribute": "02032",

  "CheckType": "NEL",

  "CheckLevel": "SET",

  "Version": "M",

  "VisibilityScope": "S"

},

{

  "ConditionNumber": "E51313387",

  "SheetNumber": "0016",

  "Attribute": "02032",

  "CheckType": "NEL",

  "CheckLevel": "SET",

  "Version": "M",

  "VisibilityScope": "S"

},

{

  "ConditionNumber": "E51313388",

  "SheetNumber": "0016",

  "Attribute": "02032",

  "CheckType": "NEL",

  "CheckLevel": "SET",

  "Version": "M",

  "VisibilityScope": "S"

},

{

  "ConditionNumber": "E51313389",

  "SheetNumber": "0016",

  "Attribute": "02032",

  "CheckType": "NEL",

  "CheckLevel": "SET",

  "Version": "M",

  "VisibilityScope": "S"

},

{

  "ConditionNumber": "E51313390",

  "SheetNumber": "0016",

  "Attribute": "02032",

  "CheckType": "NEL",

  "CheckLevel": "SET",

  "Version": "M",

  "VisibilityScope": "S"

},

{

  "ConditionNumber": "E75073970",

  "SheetNumber": "0015",

  "Attribute": "02032",

  "CheckType": "NEL",

  "CheckLevel": "SET",

  "Version": "M",

  "VisibilityScope": "S"

},

{

  "ConditionNumber": "E75073971",

  "SheetNumber": "0015",

  "Attribute": "02032",

  "CheckType": "NEL",

  "CheckLevel": "SET",

  "Version": "K",

  "VisibilityScope": "S"

}

],

“SecurityInfos”: null

}

In above results I want to know if I have any data with Version = K, Please suggest on how can I extract data which is with data as Version = K from above JSON

Hi @Hemasai06

Try this:

jsonObject = Deserialize JSON (Input: yourJsonString)(Use deseriliaze JSON activity)

For Each through jsonObject("Conditions")
    If (item("Version").ToString = "K")
        Message box(Item.ToString)

This will help!

https://aneejian.com/deserialize-json-uipath/

Hello @Hemasai06

Sequence (Main Sequence)
Deserialize JSON (input: Your JSON data) => jsonObject

For Each (item in jsonObject("Conditions"))
    If (item("Version").ToString = "K")
        Write Line (or perform desired action)
    End 

Thanks & Cheers!!!

@Hemasai06

assign jsonData varabletype is string
jsonData = “[{”“ConditionNumber”": "“E51248069"”, ““SheetNumber””: ““0016"”, ““Attribute””: ““02032"”, ““CheckType””: ““NEL””, ““CheckLevel””: ““SET””, ““Version””: ““M””, ““VisibilityScope””: ““S””}, {”“ConditionNumber””: "“E75073971"”, ““SheetNumber””: "“0015"”, ““Attribute””: ““02032"”, ““CheckType””: ““NEL””, ““CheckLevel””: ““SET””, ““Version””: ““K””, ““VisibilityScope””: ““S””}]”

   assign data 
    data = Newtonsoft.Json.JsonConvert.DeserializeObject(Of List(Of DataItem))(jsonData)

    ' Filter data where Version = "K"
     assign filterData

filteredData = data.Where(Function(item) item.Version = “K”).ToList()

    For Each item In filteredData
        Console.WriteLine($"ConditionNumber: {item.ConditionNumber}, Version: {item.Version}")

assign the values you want

 ConditionNumber As String
    Public Property SheetNumber As String
     Attribute As String
     CheckType As String
    CheckLevel As String
     Version As String
   VisibilityScope As String

cheerss…!