I am trying to get this block of VB.NET Json Code to work: -


i trying block of vb.net json code work: there 2 issues -'responsebody' loading valid data array want object data. in addition line 'for each item jproperty in results' throwing error-'unable cast object of type 'newtonsoft.json.linq.jobject' type 'newtonsoft.json.linq.jproperty'. ' have ideas?

 public async function examplemethodasync() task(of string)             dim client = new httpclient()             dim querystring = httputility.parsequerystring(string.empty)              ' request headers             client.defaultrequestheaders.add("key", "xxx")              dim uri = "xxx" & querystring.tostring()              dim response httpresponsemessage              ' request body             dim bytedata byte() = encoding.utf8.getbytes(uri)              using content = new bytearraycontent(bytedata)                 content.headers.contenttype = new          mediatypeheadervalue("application/json")                 response = await client.postasync(uri, content)                 response.ensuresuccessstatuscode()                 dim responsebody string = await response.content.readasstringasync()                   dim ser jarray = jarray.parse(responsebody)                   dim output string = ""                 dim toolname string = ""                 dim index_ string = ""                 dim text string = ""                 dim value_ string = ""                 dim temnumber string = ""                 dim itemtext string = ""                 'dim result = jsonconvert.deserializeobject(of arraylist)(responsefromserver)                 dim type jobject                 dim results list(of jtoken) = ser.children().tolist                  each item jproperty in results                     item.createreader()                     if item.name = "toolname:"                         toolname = item.value                     end if                     if item.name = "index:"                         index_ = item.value                     end if                     select case item.name                         case "assessmentitems"                             output += "assessmentitems:" + vbcrlf                             each comment jobject in item.values                                 dim u string = comment("temnumber")                                 dim d string = comment("itemtext")                                 temnumber = u                                 itemtext = d                             next                          case "responses"                             output += "responses:" + vbcrlf                             each comment jobject in item.values                                 dim f string = comment("text")                                 dim g string = comment("value")                                 text = f                                 value_ = g                             next                       end select 


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -