Linq Query To get data from json

Hello, I made a script for the Invoke Code activity.
arg1 is the text of the file read with Read Text File
arg2 is the “RuleId” argument and value is the result String
Being a particular JSON file the format can be unrecognized.
So better use no encoding instead of
“typescript/text”, or “application/json”
An “UTF-8” type encoding can be used as well.
Unfortunately, reading the file from the disk is very slow.
The code for this script is the following:

Dim doc As System.Text.Json.JsonDocument
doc = System.Text.Json.JsonDocument.Parse(arg1)

Dim id As String
Dim rules As System.Text.Json.JsonElement
rules = doc.RootElement.GetProperty(“Rules”)

Dim n As Integer = rules.GetArrayLength()

For i = 0 To n -1 Step 1
id = rules.Item(i).GetProperty(“RuleId”).GetString()
If (id = arg2) Then
value = rules.Item(i).GetProperty(“DefaultErrorLevel”).GetString()
''System.Windows.Forms.MessageBox.Show(value)
End If
Next i

Hope it will help somehow, Adrian