Click here to Skip to main content
15,898,134 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Linq RemoveRange, or a better idea Pin
Richard Deeming24-Oct-17 9:52
mveRichard Deeming24-Oct-17 9:52 
GeneralRe: Linq RemoveRange, or a better idea Pin
jkirkerx25-Oct-17 11:36
professionaljkirkerx25-Oct-17 11:36 
QuestionVB Linq, got 1 duplicate in a GroupBy Call Pin
jkirkerx16-Oct-17 13:15
professionaljkirkerx16-Oct-17 13:15 
AnswerRe: VB Linq, got 1 duplicate in a GroupBy Call Pin
Richard Deeming17-Oct-17 2:08
mveRichard Deeming17-Oct-17 2:08 
GeneralRe: VB Linq, got 1 duplicate in a GroupBy Call Pin
jkirkerx17-Oct-17 6:28
professionaljkirkerx17-Oct-17 6:28 
AnswerRe: VB Linq, got 1 duplicate in a GroupBy Call Pin
Eddy Vluggen17-Oct-17 2:09
professionalEddy Vluggen17-Oct-17 2:09 
GeneralRe: VB Linq, got 1 duplicate in a GroupBy Call Pin
jkirkerx17-Oct-17 6:24
professionaljkirkerx17-Oct-17 6:24 
QuestionReading complex JSON objects with Newtonsoft Pin
A_Griffin15-Oct-17 1:32
A_Griffin15-Oct-17 1:32 
I've tried so many approaches... a simple "one-tier" JSON structure us easy, but when it comes to more complex objects, I cannot figure this out, despite help from various articles here and elsewhere (thought here aren't that many I've found.)

A typical structure I need to parse is like this:

XML
{
   "odata.metadata" : "blahblah",
   "value" : [
      {
         "prop1" : 69,
         "prop2" : 96,
         "prop3" : "Blah",
         "prop4" : "Blah",
         "prop5" : [
            {
               "sub1" : 269,
               "sub2" : 3,
               "sub3" : "something",
               "sub4" : null
            }
         ],
         "prop6" : []
      },
      {
         "prop1" : 23,
         "prop2" : 45,
         "prop3" : "Blah2",
         "prop4" : null,
         "prop5" : [],
         "prop6" : [
            {
               "sub1" : 169,
               "sub2" : 7,
               "sub3" : null,
               "sub4" : "2017-10-01"
            }
	 ]
      }
   ],
   "odata.nextLink" : "blahblahURL"
}

They all have the same three top-level elements: "odata.metadata", "odata.nextLink" and "value", and it is only the "value" element that may differ - some will have more or fewer properties, but typically as above.

I start by defining a class:
VB
Friend MustInherit Class Response
   <JsonProperty("odata.metadata")>
   Public MetaData As String
   <JsonProperty("odata.nextLink")>
   Public NextLink As String
End Class

Friend Class ClsTest
   Inherits Response
   <JsonProperty("value")>
   Public Property TESTS() As Linq.JArray
End Class

I keep ClsTest separate as I may want to have different ones for different JSON structures, depending on what the final approach is....

then I can deserialize it in two different ways - if "json" is the string representing the object above:

1. using the class:
XML
Dim cls As clsTest = JsonConvert.DeserializeObject(Of clsTest)(json)

2. or using a JObject
VB
Dim jsonObject As Linq.JObject = JsonConvert.DeserializeObject(json)

but after each I can't get beyond extracting the "odata" values - I can't figure out how to get the "values" and read them into something I can work with in my application: - classes, lists arrays, whatever...

I realise this is still a rather general question and maybe not specific enough, but really any hints or help will be appreciated...

modified 15-Oct-17 7:53am.

AnswerRe: Reading complex JSON objects with Newtonsoft Pin
A_Griffin16-Oct-17 23:36
A_Griffin16-Oct-17 23:36 
QuestionCompletely disabling Scrolling in a DataGridView Pin
Peter R. Fletcher14-Oct-17 10:57
Peter R. Fletcher14-Oct-17 10:57 
AnswerRe: Completely disabling Scrolling in a DataGridView - SOLVED Pin
Peter R. Fletcher16-Oct-17 11:29
Peter R. Fletcher16-Oct-17 11:29 
QuestionHow do I change XML-driven menu strip's font? Vb.net Pin
Member 1338609314-Oct-17 4:18
Member 1338609314-Oct-17 4:18 
AnswerRe: How do I change XML-driven menu strip's font? Vb.net Pin
Richard MacCutchan14-Oct-17 6:48
mveRichard MacCutchan14-Oct-17 6:48 
QuestionChange the format Pin
Felix Holzinger7-Oct-17 11:51
Felix Holzinger7-Oct-17 11:51 
AnswerRe: Change the format Pin
Richard MacCutchan10-Oct-17 21:04
mveRichard MacCutchan10-Oct-17 21:04 
Questionsoftwares for agriculture irrigation with the help of visual basic Pin
Member 134513307-Oct-17 4:49
Member 134513307-Oct-17 4:49 
AnswerRe: softwares for agriculture irrigation with the help of visual basic Pin
OriginalGriff7-Oct-17 4:50
mveOriginalGriff7-Oct-17 4:50 
AnswerRe: softwares for agriculture irrigation with the help of visual basic Pin
Mycroft Holmes7-Oct-17 15:15
professionalMycroft Holmes7-Oct-17 15:15 
Questionsoftwares for agriculture irrigation with the help of visual basic Pin
Member 134513307-Oct-17 4:06
Member 134513307-Oct-17 4:06 
AnswerRe: softwares for agriculture irrigation with the help of visual basic Pin
OriginalGriff7-Oct-17 4:50
mveOriginalGriff7-Oct-17 4:50 
QuestionDataGridView with Two Datatables and Combobox Lookup Pin
billsut4-Oct-17 2:19
billsut4-Oct-17 2:19 
AnswerRe: DataGridView with Two Datatables and Combobox Lookup Pin
Mycroft Holmes4-Oct-17 13:30
professionalMycroft Holmes4-Oct-17 13:30 
QuestionResizing images Pin
A_Griffin3-Oct-17 2:03
A_Griffin3-Oct-17 2:03 
AnswerRe: Resizing images Pin
Richard MacCutchan3-Oct-17 6:31
mveRichard MacCutchan3-Oct-17 6:31 
GeneralRe: Resizing images Pin
A_Griffin3-Oct-17 8:14
A_Griffin3-Oct-17 8:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.