JSON files

Post

Posted
Rating:
#1 (In Topic #133)
Avatar
Guru
cogier is in the usergroup ‘Guru’
I am trying to enumerate the 'Keys' in a Gambas decoded JSON file. If I run the code below I can print the data associated with the key but not the keys.

Code

Public Sub Main()
Dim vNew As Variant
Dim sNew As String

Shell "wget -O - https://poloniex.com/public?command=returnTicker" To sNew

vNew = Json.decode(sNew) ''Requires component 'gb.web'

Print vNew["BTC_BCN"]["last"]

Stop

End

I am looking to get a list of 'Keys' into an array ["BTC_BCN","BTC_BELA",…] and ["id","last","lowestAsk"…]. Any ideas appreciated.
Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
stevedee is in the usergroup ‘Regular’
Try this:-

Code

Public Sub Main()
Dim vNew As Variant
Dim sNew As String
Dim cBitcoin As Collection
Dim ciBitcoin As Collection

Shell "wget -O - https://poloniex.com/public?command=returnTicker" To sNew


vNew = Json.decode(sNew) ''Requires component 'gb.web'
cBitcoin = vNew

' Print cBitcoin.Length

For Each ciBitcoin In cBitcoin
  Print cBitcoin.Key, cBitcoin[cBitcoin.Key]["last"]
Next

Stop

End
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
Thanks SteveDee. There is no doubt that this works but I am having trouble getting my head around the logic. I haven't worked out how to get the next set of 'Keys', but this is a start, thanks.  :?
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
stevedee is in the usergroup ‘Regular’
The clues are in your first post, but I don't know how much time you have spent playing around with Collections. As your screen shots show, vNew contains a collection of collections. Each trading pair in the collection contains its own collection of data, where the trading pair name is the Key string.

So I've taken the variant vNew (which is returned from Json.Decode) and copied it into the new collection cBitcoin. Then I enumerate each item in the collection cBitcoin by asking: "FOR EACH collection (ciBitcoin) IN the collection (cBitcoin) please return the Key"

The collection property cBitcoin.Key returns each collection key as a string (e.g. BTC_ETH). And then I can use:

Code

cBitcoin[cBitcoin.Key]["last"]
…to get the corresponding Last value.

In VB6 you could also access a collection using a numeric index, something like:

Code

strKeyName = cBitcoin[2].Name
…would give you the 3rd item Key in the collection. But Gambas does not support a numeric index.

I'm glad you used the Poloniex api query: "https://poloniex.com/public?command=returnTicker"
..as the main collection only references sub-collections, which makes the code straight forward.

As an additional exercise, I spent an hour or two this morning trying to do the same thing with:
 "https://www.cryptocompare.com/api/data/coinlist/"
This collection includes a mixture of strings and collections, and I can't think how to deal with this.

What additional data are you trying to retrieve? The remaining data for each trading pair in your example is similar to "last". So for example, if you wanted the 24hr High value use:

Code

 cBitcoin[cBitcoin.Key]["high24hr"]

And if you want to filter trading pairs, you could just display Ether markets:

Code

For Each ciBitcoin In cBitcoin
  If InStr(cBitcoin.Key, "ETH") > 0 Then
    Print cBitcoin.Key, cBitcoin[cBitcoin.Key]["last"], cBitcoin[cBitcoin.Key]["high24hr"]
  Endif
Next

I hope this helps, but come back if its still gibberish.
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
jornmo is in the usergroup ‘Regular’
As an additional exercise, I spent an hour or two this morning trying to do the same thing with:
"https://www.cryptocompare.com/api/data/coinlist/"
This collection includes a mixture of strings and collections, and I can't think how to deal with this.

I think that should be pretty easy actually. A recursive function to do the data extraction, and start it with a test like this:/lang/is - Gambas Documentation

(Haven't actually run this code)

Code (gambas)

  1. Public Sub GetCollectionData(Col as Collection)
  2.  
  3.  
  4.   For Each v In Col
  5.       GetCollectionData(v)
  6.     Else
  7.       Print("Key: " & Col.Key & " Value: " & v
  8.     End If
  9.  
  10.  

Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
stevedee is in the usergroup ‘Regular’
Yes, I discussed it with #3 son last night (he is doing Computer Science at Uni, but does not code in Gambas) and this morning I came up with this:-

Code

  Shell "wget -O - https://www.cryptocompare.com/api/data/coinlist/" To sNew
  cBitcoin = Json.decode(sNew, True)

  For Each ciBitcoin In cBitcoin["Data"]
    strCrypto.Resize(intCoinCount + 1)
    strCrypto.Add(ciBitcoin["Name"] & ":" & ciBitcoin["CoinName"])
    Inc intCoinCount
  Next

  strCrypto.Sort   'sort them in alpha order
  For index = 0 To strCrypto.Count - 1
    Print strCrypto[index]
  Next
  Print "Total:", intCoinCount

Wow! there are 1507 cryptos listed on this site!

The important bit is the For Each line that just enumerates the "Data" object in the json text. The rest just puts the text into an array and creates pretty-text.
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Guru
cogier is in the usergroup ‘Guru’
This started with a question from Brad on the 'other' forum (which seems to be a forum no longer). I managed to sort the problem for which I recveived the heart warming "Awesome! Thank you so much!" but I thought I'd dig further and automatically get all the data into arrays. The URL I am using came from Brad.

Your solution worked but confused me as I have only ever enumerated with the variable after 'Each' not with the variable after 'In'

e.g.
For Each ciBitcoin In cBitcoin
  Print ciBitcoin.Key
Next

But you worked with ciBitcoin, it works but I can't work out the logic here.

For Each ciBitcoin In cBitcoin
  Print cBitcoin.Key
Next

I was trying to get a list of the other keys as well ["id","last",lowestAsk"…].

Using your example website you end up with a list of keys ["Response", "Message"…"Data"…] then ["LC", "HEAT", "EXB"…] and open up the Collection and there are more keys ["id", "Url", "ImageUrl"…].

Basically I can get the information out as I can see keys like "last" but I thought it would be nice for Gambas to get all that detail for me.
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Regular
stevedee is in the usergroup ‘Regular’

cogier said

…Your solution worked but confused me as I have only ever enumerated with the variable after 'Each' not with the variable after 'In'

e.g.
For Each ciBitcoin In cBitcoin
  Print ciBitcoin.Key
Next

But you worked with ciBitcoin, it works but I can't work out the logic here.

For Each ciBitcoin In cBitcoin
  Print cBitcoin.Key
Next


Take a look at this For Each…In… example:-


Code

Public Sub Main()
Dim Cars As New Collection
Dim Make As String

  Cars["Ford"] = 2
  Cars["Audi"] = 1
  Cars["Jaguar"] = 4
  Cars["Lada"] = 3
  
  For Each Make In Cars
    Print Make;
  Next
End


This "Cars" collection consists of 4 string elements, each one has an integer value assigned to it.
We could print the integer value of an individual element by directly addressing the element, e.g.

Code

Print Cars["Lada"]

…would result in: 3

But by creating a string variable ("Make") we can specify that we want to step through each string element in Cars, assign it to Make and then print the corresponding integer value for Make. The result is that the integers are printer in the order they appear in the collection: 2 1 4 3

In the Crypto example, I am not looking for a string element in the Collection, I'm looking for other Collection elements. So I Dim a collection ("ciBitcoin") and use this:-

Code

For Each ciBitcoin In cBitcoin
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Regular
stevedee is in the usergroup ‘Regular’
 Reading my last post again this morning, I realise something is not quite right with my explanation.

Although the Cars example appears to work, the variable "Make" should be an integer, not a string. The reason it appears to work as a string is that Gambas just quietly converts each integer into a string.

Even if you replace the integers in this example with booleans (True or False) the code still runs without error, but converts True to "T" and false to "".
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Guru
cogier is in the usergroup ‘Guru’
Thanks for all the effort here. I can't get much from the Jornmo example. I tried the following

Code (gambas)

  1. Public Sub Main()
  2. Dim cCol, cCol1 As Collection
  3.  
  4. Shell "wget -O - https://poloniex.com/public?command=returnTicker" To sNew
  5.  
  6. vNew = Json.decode(sNew) ''Requires component 'gb.web'
  7.  
  8. cCol = vNew
  9.  
  10. For Each cCol1 In cCol
  11.   GetCollectionData(cCol1)
  12.  
  13.  
  14. Public Sub GetCollectionData(Col As Collection)
  15.  
  16. For Each v In Col
  17.   If v Is Collection Then ''Error here 'Wanted object got integer instead'
  18.     GetCollectionData(v)
  19.   Else
  20.     Print "Key: " & Col.Key & " Value: " & v
  21.   End If
  22.  
  23.   Print "Key: " & Col.Key & " Value: " & v
  24.  

This got me: -
Key: id Value: 7
Key: id Value: 8
Key: id Value: 10
Key: id Value: 12
Key: id Value: 13
Key: id Value: 14
…….

Thanks for the explanation SteveDee
I discussed it with #3 son last night (he is doing Computer Science at Uni, but does not code in Gambas)
 :o   He'll need lots of these then "{}{}{}{}{}{}{}".  ;)

Going to the pub now, I will get a friend to look at all this and see if he can add anything to this debate.
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Regular
jornmo is in the usergroup ‘Regular’
 I can't get much from the Jornmo example. I tried the following

Try replacing:

Code (gambas)


With:

Code (gambas)


Online now: No Back to the top

Post

Posted
Rating:
#12
Avatar
Guru
cogier is in the usergroup ‘Guru’
Your code works but the 'TypeOf (v)' is never 'True' so is not called.

This code will get the 'Keys' of the 1st and 2nd depth.

Code (gambas)

  1. Public Sub Main()
  2. Dim vNew, vTemp As Variant
  3. Dim cCol, cCol1 As Collection
  4.  
  5. Shell "wget -O - https://poloniex.com/public?command=returnTicker" To sNew
  6.  
  7. vNew = Json.decode(sNew) ''Requires component 'gb.web'
  8.  
  9. cCol = vNew
  10.  
  11. For Each cCol1 In cCol
  12.   Print cCol.Key
  13.  
  14. For Each vTemp In cCol1
  15.   Print cCol1.Key
  16.  

Result
…..
BTC_OMG
ETH_OMG
BTC_GAS
ETH_GAS
id
last
lowestAsk
highestBid
percentChange
baseVolume
quoteVolume
isFrozen
high24hr
low24hr
Online now: No Back to the top

Post

Posted
Rating:
#13
Avatar
Regular
jornmo is in the usergroup ‘Regular’
Your code works but the 'TypeOf (v)' is never 'True' so is not called.

I suppose that's because your JSON file does not produce collections inside a collection, as with stevedee?!

Online now: No Back to the top

Post

Posted
Rating:
#14
Trainee
Hi Guys,

TypeOf(v) is true, if you pass the whole result from Json.decode… see below

Code (gambas)

  1. Public Sub Main()
  2.  
  3.   Dim vNew As Variant
  4.   Dim sNew As String
  5.  
  6.   Shell "wget -O - https://poloniex.com/public?command=returnTicker" To sNew
  7.  
  8.   vNew = Json.decode(sNew) 'Requires component 'gb.web'
  9.  
  10.   GetCollectionData(vNew)
  11.  
  12.  
  13. Public Sub GetCollectionData(Col As Collection)
  14.  
  15.  
  16.   For Each v In Col
  17.     If TypeOf(v) = gb.Object Then
  18.       Print "Collection: Key: " & Col.Key
  19.       GetCollectionData(v)
  20.     Else
  21.       Print "Key: " & Col.Key & " Value: " & v
  22.     End If
  23.   Next
  24.  
  25.  

Results:
Collection: Key: BTC_BCN
Key: id Value: 7
Key: last Value: 0.00000034
Key: lowestAsk Value: 0.00000035
Key: highestBid Value: 0.00000034
Key: percentChange Value: -0.02857142
Key: baseVolume Value: 39.58161827
Key: quoteVolume Value: 115639167.85117029
Key: isFrozen Value: 0
Key: high24hr Value: 0.00000036
Key: low24hr Value: 0.00000033
Collection: Key: BTC_BELA
Key: id Value: 8
Key: last Value: 0.00003115

 Cheers
Matt
Online now: No Back to the top

Post

Posted
Rating:
#15
Trainee
Hi Guys,

I think the "Collection" could do with a ".Keys" as well as ".Key" function…. ?

In the meantime, see my GetKeys(Collection) function below:

Code (gambas)

  1. Public Sub Main()
  2.  
  3.   Dim vNew As Variant
  4.   Dim sNew As String
  5.   Dim Keys1 As String[]
  6.   Dim Keys2 As String[]
  7.  
  8.   Shell "wget -O - https://poloniex.com/public?command=returnTicker" To sNew
  9.  
  10.   vNew = Json.decode(sNew) 'Requires component 'gb.web'
  11.  
  12.   Keys1 = GetKeys(vNew)
  13.   Keys2 = GetKeys(vNew[Keys1[0]])
  14.  
  15.   Print Keys1[0]
  16.   Print Keys2[0]
  17.  
  18.  
  19. Public Sub GetKeys(Col As Collection) As String[]
  20.  
  21.   Dim Keys As New String[]
  22.  
  23.   For Each v In Col
  24.     Keys.Add(Col.Key)
  25.   Next
  26.  
  27.   Return Keys
  28.  

Cheers
Matt

 Cheers
Matt
Online now: No Back to the top

Post

Posted
Rating:
#16
Avatar
Regular
jornmo is in the usergroup ‘Regular’
 If you tick "Do not automatically parse URLs" below the posting form, the URL's will display properly inside the code highlighter. (I will sooner or later need to make the plugin skip parsing automatically)

Online now: No Back to the top

Post

Posted
Rating:
#17
Avatar
Regular
jornmo is in the usergroup ‘Regular’
I think the "Collection" could do with a ".Keys" as well as ".Key" function…. ?

Agree  8-)

Online now: No Back to the top

Post

Posted
Rating:
#18
Trainee
i am getting unknown identifier Json error
anyone can help ?

<IMG src="https://pix.cobrasoftwares.org/images/2022/03/28/Screenshot-from-2022-03-28-21-57-02.png">
Online now: No Back to the top

Post

Posted
Rating:
#19
Avatar
Guru
cogier is in the usergroup ‘Guru’
Welcome to the forum.

Try going to Project > Properties… > Components and ensure you have the gb.util.web component loaded.

<IMG src="https://www.cogier.com/gambas/Json1.png"> </IMG>
Online now: No Back to the top

Post

Posted
Rating:
#20
Trainee
Hello! New to Gambas here. I was trying to do an example using httpClient instead of Wget but no matter what i always end getting Null when i try to JsonDecode.
Does anyone know what i may be doing wrong here? Any help is appreciated.

Code

' Gambas class file

Public Sub Form_Open()
  
  Dim myhttp As HttpClient
  Dim cadena_respuesta As String
  Dim cadena_peticion As String  
  
  Dim vNew As Variant
  Dim sNew As String
  Dim Keys1 As String[]
  Dim Keys2 As String[]
  
  myhttp = New HttpClient
  myhttp.Async = False
  myhttp.Timeout = 60
  myhttp.URL = "https://poloniex.com/public?command=returnTicker"
  myhttp.Get
  
  cadena_respuesta = ""
  JSON.Decode(cadena_respuesta)
  sNew = cadena_respuesta
  
  Print cadena_respuesta
  vNew = Json.decode(sNew) 'Requires component 'gb.web'
  
  Keys1 = GetKeys(vNew)
  Keys2 = GetKeys(vNew[Keys1[0]])
  
  Print Keys1[0]
  Print Keys1[1]
  Print Keys2[0]  
  
End

Public Sub GetKeys(Col As Collection) As String[]
  
  Dim Keys As New String[]
  Dim v As Variant
  
  For Each v In Col
    Keys.Add(Col.Key)
  Next
  
  Return Keys
End
Online now: No Back to the top

Post

Posted
Rating:
#21
Avatar
Guru
cogier is in the usergroup ‘Guru’
Hi DayanUt31 and welcome to the forum.

I suggest you start a 'New Topic' next time you have a question.
Tip: - When adding Gambas code to your posts use the 'gb' button. The code looks a lot better, see below
<IMG src="https://www.cogier.com/gambas/gb_button.png"> </IMG>  

Regarding your query, put the code below in a Graphical Application and run it, hopefully it will answer some of your questions.

Code (gambas)

  1. ' Gambas class file
  2.  
  3. ''*******************************
  4. ''REQUIRES gb.net.curl and gb.web
  5. ''*******************************
  6.  
  7. GridViewData As GridView
  8.  
  9. Public Sub Form_Open()
  10.  
  11.   BuildForm
  12.   GetData
  13.  
  14.  
  15. Public Sub GetData()
  16.  
  17.   Dim myhttp As HttpClient
  18.   Dim sResult, sVal As String
  19.   Dim vResult As Variant
  20.   Dim cCol As Collection
  21.   Dim iRow As Integer
  22.  
  23.   myhttp = New HttpClient
  24.   myhttp.Async = False
  25.   myhttp.Timeout = 60
  26.   myhttp.URL = "https://poloniex.com/public?command=returnTicker"
  27.   myhttp.Get
  28.  
  29.   If Lof(myhttp) Then sResult = Read #myhttp, Lof(myhttp)
  30.  
  31.   vResult = JSON.Decode(sResult)
  32.  
  33.   For Each cCol In vResult
  34.     For Each sVal In cCol
  35.       Inc GridViewData.Rows.Count
  36.       GridViewData[iRow, 0].Text = cCol.Key
  37.       GridViewData[iRow, 1].Text = sVal
  38.       Inc iRow
  39.     Next
  40.     Inc GridViewData.Rows.Count
  41.     Inc iRow
  42.   Next
  43.  
  44.   GridViewData.Columns.Width = -1
  45.  
  46.  
  47. Public Sub BuildForm()
  48.  
  49.   With Me
  50.     .Height = 1000
  51.     .Width = 500
  52.     .Padding = 5
  53.     .Arrangement = Arrange.Vertical
  54.     .Center
  55.  
  56.   With GridViewData = New GridView(Me) As "GridViewData"
  57.     .Header = GridView.Both
  58.     .Expand = True
  59.     .Columns.Count = 2
  60.     .Columns[0].Title = "Key"
  61.     .Columns[1].Title = "value"
  62.  
Online now: No Back to the top

Post

Posted
Rating:
#22
Trainee
Thank you a lot for your help! i was able to understand more about Json decode in gambas.
I made some small adjustements to the code you provide before so instead i can get the data collection printed in a terminal.
This is how it looks:

Code (gambas)

  1. Public Sub GetData()
  2.  
  3.   Dim myhttp As HttpClient
  4.   Dim sResult, sVal As String
  5.   Dim vResult As Variant
  6.   Dim cCol As Collection
  7.   Dim iRow As Integer
  8.  
  9.   myhttp = New HttpClient
  10.   myhttp.Async = False
  11.   myhttp.Timeout = 60
  12.   myhttp.URL = "https://poloniex.com/public?command=returnTicker"
  13.   myhttp.Get
  14.  
  15.   If Lof(myhttp) Then sResult = Read #myhttp, Lof(myhttp)
  16.  
  17.   vResult = JSON.Decode(sResult)
  18.  
  19.   For Each cCol In vResult
  20.     For Each sVal In cCol
  21.       Print "" & cCol.Key & ": " & sVal
  22.      
  23.     Next
  24.     Print "____________________________"
  25.   Next
  26.  

Just one last question.
For some reason, when i try to change the url from this example to this one:
https://jsonplaceholder.typicode.com/users

it gives me an error telling me "Wanted string, got Collection instead"
<IMG src="https://ibb.co/54RGPZP"> </IMG>

why is this? and do you know how could i adapt this code to work with this specific Url?
thanks for all the support.
Online now: No Back to the top

Post

Posted
Rating:
#23
Guru
BruceSteers is in the usergroup ‘Guru’
Did you include the  "<a href=" parts by mistake?
url strings were added to the URL by the forum and should not be there (Charlie forgot to select the  "Do not automatically parse URLs" option)

this is not right…

Code (gambas)

  1.   myhttp.URL = "<a href="https://poloniex.com/public?command=returnTicker" class="postlink">https://poloniex.com/public?command=returnTicker</a>"
  2.  

it should just be this..

Code (gambas)

  1. myhttp.URL = "https://poloniex.com/public?command=returnTicker"
  2.  

or this even

Code (gambas)

  1. myhttp.URL = "https://jsonplaceholder.typicode.com/users"
  2.  
Online now: No Back to the top

Post

Posted
Rating:
#24
Avatar
Guru
cogier is in the usergroup ‘Guru’
Did you include the "<a href=" parts by mistake?
url strings were added to the URL by the forum and should not be there (Charlie forgot to select the "Do not automatically parse URLs" option)

Opps! :?
I have fixed this.

The reason that the new URL creates a crash is due to the fact that there are Collections inside the Collections and I notice, there is another Collection inside that!
<IMG src="https://www.cogier.com/gambas/Collections.png"> </IMG>

The code below will skip over the error. Programming the code further depends on what your program is expecting to achieve.

Code (gambas)

  1. ' Gambas class file
  2.  
  3. ''*******************************
  4. ''REQUIRES gb.net.curl and gb.web
  5. ''*******************************
  6.  
  7. GridViewData As GridView
  8.  
  9. Public Sub Form_Open()
  10.  
  11.   BuildForm
  12.   GetData
  13.  
  14.  
  15. Public Sub GetData()
  16.  
  17.   Dim myhttp As HttpClient
  18.   Dim sResult As String
  19.   Dim vVal As Variant
  20.   Dim vResult As Variant
  21.   Dim cCol As Collection
  22.   Dim iRow As Integer
  23.  
  24.   myhttp = New HttpClient
  25.   myhttp.Async = False
  26.   myhttp.Timeout = 60
  27.   myhttp.URL = "https://jsonplaceholder.typicode.com/users"
  28.   myhttp.Get
  29.  
  30.   If Lof(myhttp) Then sResult = Read #myhttp, Lof(myhttp)
  31.  
  32.   vResult = JSON.Decode(sResult)
  33.  
  34.   For Each cCol In vResult
  35.     For Each vVal In cCol
  36.       Inc GridViewData.Rows.Count
  37.       GridViewData[iRow, 0].Text = cCol.Key
  38.       Try GridViewData[iRow, 1].Text = vVal
  39.       Inc GridViewData.Rows.Count
  40.       Inc iRow
  41.     Next
  42.   Next
  43.  
  44.   GridViewData.Columns.Width = -1
  45.  
  46.  
  47. Public Sub BuildForm()
  48.  
  49.   With Me
  50.     .Height = 1000
  51.     .Width = 500
  52.     .Padding = 5
  53.     .Arrangement = Arrange.Vertical
  54.     .Center
  55.  
  56.   With GridViewData = New GridView(Me) As "GridViewData"
  57.     .Header = GridView.Both
  58.     .Expand = True
  59.     .Columns.Count = 2
  60.     .Columns[0].Title = "Key"
  61.     .Columns[1].Title = "value"
  62.  
  63.  
Online now: No Back to the top

Post

Posted
Rating:
#25
Trainee
Thank you very much for all the help, i managed to get it running like this:

Code (gambas)

  1. ' Gambas class file
  2.  
  3. ''*******************************
  4. ''REQUIRES gb.net.curl and gb.web
  5. ''*******************************
  6.  
  7. GridViewData As GridView
  8.  
  9. Public Sub Form_Open()
  10.   GetData
  11.  
  12.  
  13. Public Sub GetData()
  14.  
  15.   Dim myhttp As HttpClient
  16.   Dim sResult As String
  17.   Dim vVal As Variant
  18.   Dim vResult As Variant
  19.   Dim cCol As Collection
  20.   Dim iRow As Integer
  21.  
  22.   myhttp = New HttpClient
  23.   myhttp.Async = False
  24.   myhttp.Timeout = 60
  25.   myhttp.URL = "https://jsonplaceholder.typicode.com/users"
  26.   myhttp.Get
  27.  
  28.   If Lof(myhttp) Then sResult = Read #myhttp, Lof(myhttp)
  29.  
  30.   vResult = JSON.Decode(sResult)
  31.  
  32.   For Each cCol In vResult
  33.     For Each vVal In cCol
  34.       Print "" & cCol.Key & "", ": ", vVal
  35.     Next
  36.     Print "-------------------------"
  37.   Next
  38.  

The only bad thing is i get different results in the company name. It shows like this "company :       (Collection 0x56185d800b98)"
I was thinking i could get around this by adding an if inside the for each so it can change it to Collection or variant depending on the result in vVal but i would need to give it a try.
Online now: No Back to the top
1 guest and 0 members have just viewed this.