troubleshooting Question

Proper JSON Syntax for extracting Data from Nested Arrays

Avatar of Rick Becker
Rick BeckerFlag for United States of America asked on
.NET ProgrammingJSON
6 Comments1 Solution45 ViewsLast Modified:
Greetings All..

Ok I am very new to JSON but I the need to use and learn it. I have been able to search the internet to get some help in getting it setup and running on Very Simple JSON files/script. I am Visual Studio 2017 and VB.NET and I  have loaded in the NewtonSoft.Json  libraries which is working very well. However, So far I have only  been working with file/scripts that are simple and a single Array of elements/objects.

The SYNTAX for extracting Data from these elements is pretty easy and pretty straight forward and I am successful in this Simple Data...

However I now have to extraxt some data from some larger files/scripts which contains MULTIPLE Levels of Arrays. These file are 'Customer Order' files that contains an Array of ORDERS each of which can contain an Array of Items.. I need to be able to extract the SKU data from each of the ITEMS on the ORDER'

The following is my current code and below that is a sample of a Single ORDER with the 'Nested' ITEMS;

        Call xmlHttp2.open("GET", sContactURL, False)
        
        xmlHttp2.setRequestHeader("Authorization:", " Basic " + EncodedShipStationID)
        Call xmlHttp2.send()

        'Get the server's response
        sResponse = xmlHttp2.responseText
        sResponse = Trim(sResponse)

        'Save the response  for later evaluation if needed
        RtnVal = VarStringToTextFile(TempDataStorageFolder + "\ShipStationOrderResponse1.xml", sResponse)


       
        Dim json As String = sResponse.ToString
        Dim jsonObject As Newtonsoft.Json.Linq.JObject = Newtonsoft.Json.Linq.JObject.Parse(json)

        '''Dim jsonArray As Newtonsoft.Json.Linq.JArray = jsonObject("items")

        Dim jsonArray As Newtonsoft.Json.Linq.JArray = jsonObject("orders")

        Dim CurrentSKU As String
        Dim CurrentSKU Array() As String

        CurrentSKU = ""

        For Each item As Newtonsoft.Json.Linq.JObject In jsonArray


            CurrentSKU =  CurrentSKU + item.SelectToken("orderNumber").ToString + ","
            
        Next
        CurrentSKUArray = CurrentSKU .Split(",")
        '################################################################
        MsgBox("Done")
        Cursor = Cursors.Default

Open in new window


So my main problem is that I just flat do not know how to reference  'item.SelectToken("Orders.Items.sku")

Any help with syntax for extracting data from the ITEM array/Nested arrays would be most helpful.
Thanks in advance
Rick

The following is a sample file:

ShipStationOrderResponse1.json
ASKER CERTIFIED SOLUTION
Zvonko
Systems architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2006

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 6 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004