'create JSON Object on-the-fly
dim sStr as string = Newtonsoft.Json.Linq.JObject.FromObject(New With {
.Name = "Name",
.Value = 12
}).ToString
'create JSON Object
Dim oError As Newtonsoft.Json.Linq.JObject = New Newtonsoft.Json.Linq.JObject
oError.Add(New Newtonsoft.Json.Linq.JProperty("Error", ex.Message))
oError.Add(New Newtonsoft.Json.Linq.JProperty("URL", sUrl))
'Create jArray
Dim jAssingments As New Newtonsoft.Json.Linq.JObject
For Each itm In oComputer.SchindlerSWDs
jAssingments.Add(itm.PackageName, New Newtonsoft.Json.Linq.JArray({itm.ActionRequest, itm.QueryState}))
Next
tbAssignment.Value = jAssingments.ToString
'Parse jObject
Dim jParams As Newtonsoft.Json.Linq.JObject = Nothing
Try
jParams = Newtonsoft.Json.Linq.JObject.Parse(sStr)
Catch ex As Exception
jParams = New Newtonsoft.Json.Linq.JObject()
End Try
'output
response.write(jParams("Name").ToString)
response.write(jParams.ToString(Newtonsoft.Json.Formatting.Indented))
response.write(jResults("LocationGroups").First("Id")("Value"))
'little LINQ
dim jUser = jResults("Users").Where(Function(f) f("UserName").ToString = sUsername).FirstOrDefault
For Each itm As Newtonsoft.Json.Linq.JObject In jResults("Tags")
If itm("TagName").ToString.ToLower.Equals(sTag) Then iTag = itm("Id")("Value")
If iTag IsNot Nothing Then Exit For
Next
'add
jParams.Add("DeviceId", 123)