JSON response
"error": null,
"metadata": {
"total": 1,
"limit": 1000,
"offset": 0
},
"data": [
{
"id": 1,
"description": "10 licenses",
"closeDate": "2018-05-22",
"date": "2018-05-22",
"notes": "",
"user": {
"id": 1,
"name": "Gustav Petterson",
"role": null,
"email": "apidocs#upsales.com"
},
"client": {
"name": "Pied piper",
"id": 2,
"users": [
{
"id": 1,
"name": "Gustav Petterson",
"role": null,
"email": "apidocs#upsales.com"
}
]
},
"contact": null,
"project": null,
"regDate": "2018-05-22T11:08:26.000Z",
"stage": {
"name": "Won - Order",
"id": 12
},
"probability": 100,
"modDate": "2018-05-22T11:13:59.000Z",
"clientConnection": null,
"currencyRate": 1,
"currency": "SEK",
"locked": 0,
"custom": [
{
"value": "2018-05-23",
"valueDate": "2018-05-23",
"orgNumber": 20180523,
"fieldId": 1
}
],
"orderRow": [
{
"id": 1,
"quantity": 1,
"price": 10000,
"discount": 0,
"custom": [],
"productId": 1,
"sortId": 1,
"listPrice": 10000,
"product": {
"name": "Example product",
"id": 1,
"category": null
}
}
],
"value": 10000,
"weightedValue": 10000,
"valueInMasterCurrency": 10000,
"weightedValueInMasterCurrency": 10000,
"agreement": null,
"userRemovable": true,
"userEditable": true
}
]
}
So, I've tried to parse this into my sheets but struggled for quite some time now. What I wanted to do is get all order details into a sheet, but several levels of nested parts were constantly bugging me.
In "Data" everything goes well until it runs till the first nested item "users" that is Dictionary, or "Clients" that is Collection. I tried to run the next loop to fetch nested items but I created an even bigger mess.
Sub GetOrders()
Dim sGetResult As String
Dim d_lr As Double
Dim httpObject As Object
Dim dict_json As Object
Dim objData
Dim objOrder
d_lr = LastRow(ActiveSheet)
Set httpObject = CreateObject("MSXML2.XMLHTTP")
sURL = "https://integration.upsales.com/api/v2/orders?token=" & wAdmin.Range("C4") & "&probability=100"
sRequest = sURL
httpObject.Open "GET", sRequest, False
httpObject.setRequestHeader "Accept: ", "application/json"
httpObject.Send
sGetResult = httpObject.responseText
Set dict_json = JsonConverter.ParseJson(sGetResult)
Set objData = dict_json("data")
For Each objOrder In objData
For i = 0 To objOrder.Count - 1
Debug.Print objOrder.Items()(i)
Next I
Next objOrder
End Sub
You need to test the object type and recurse accordingly.
Set dict_json = JsonConverter.ParseJson(sGetResult)
Set objdata = dict_json("data")(1)
Dim k, v, u, p
For Each k In objdata
If VarType(objdata(k)) = 9 Then ' object
If k = "user" Then
For Each u In objdata(k)
Debug.Print "user", u, objdata(k)(u)
Next
End If
If k = "client" Then
For Each u In objdata(k)
If u = "users" Then
' for each loop for users
For i = 1 To objdata(k)(u).Count
For Each p In objdata(k)(u)(i)
Debug.Print "users", i, p, objdata(k)(u)(i)(p)
Next
Next
Else
Debug.Print "client", u, objdata(k)(u)
End If
Next
End If
Else
Debug.Print k, objdata(k)
End If
Next
Related
I am trying to extract value for regularMarketPreviousClose from the Yahoo API json reponse.
I get a Run time error 424 - Object required, in the line - Set price = reply("result").
Can someone figure out what's wrong in this code. I have provided both my code and the json data I get from Yahoo API.
Here is the json response text I get from yahoo API
{
"quoteResponse": {
"result": [
{
"language": "en-US",
"region": "US",
"quoteType": "EQUITY",
"typeDisp": "Equity",
"quoteSourceName": "Delayed Quote",
"triggerable": false,
"customPriceAlertConfidence": "LOW",
"currency": "USD",
"tradeable": false,
"exchange": "PNK",
"shortName": "Tandy Leather Factory, Inc.",
"longName": "Tandy Leather Factory, Inc.",
"messageBoardId": "finmb_30741",
"exchangeTimezoneName": "America/New_York",
"exchangeTimezoneShortName": "EDT",
"gmtOffSetMilliseconds": -14400000,
"market": "us_market",
"esgPopulated": false,
"marketState": "REGULAR",
"fullExchangeName": "Other OTC",
"financialCurrency": "USD",
"regularMarketOpen": 4.95,
"averageDailyVolume3Month": 9237,
"averageDailyVolume10Day": 22020,
"fiftyTwoWeekLowChange": 1.2399998,
"fiftyTwoWeekLowChangePercent": 0.33423173,
"fiftyTwoWeekRange": "3.71 - 5.3",
"fiftyTwoWeekHighChange": -0.35000038,
"fiftyTwoWeekHighChangePercent": -0.066037804,
"fiftyTwoWeekLow": 3.71,
"fiftyTwoWeekHigh": 5.3,
"dividendDate": 1407456000,
"earningsTimestamp": 1639991127,
"earningsTimestampStart": 1648065600,
"earningsTimestampEnd": 1648238400,
"trailingAnnualDividendRate": 0,
"trailingPE": 50.510204,
"trailingAnnualDividendYield": 0,
"epsTrailingTwelveMonths": 0.098,
"epsForward": 0.43,
"epsCurrentYear": 0.26,
"priceEpsCurrentYear": 19.038462,
"sharesOutstanding": 8543230,
"bookValue": 6.038,
"fiftyDayAverage": 4.9554,
"fiftyDayAverageChange": -0.005400181,
"fiftyDayAverageChangePercent": -0.0010897568,
"twoHundredDayAverage": 4.89935,
"twoHundredDayAverageChange": 0.050649643,
"twoHundredDayAverageChangePercent": 0.010338033,
"marketCap": 42288988,
"forwardPE": 11.511627,
"priceToBook": 0.8198078,
"sourceInterval": 15,
"exchangeDataDelayedBy": 0,
"averageAnalystRating": "2.0 - Buy",
"firstTradeDateMilliseconds": 749136600000,
"priceHint": 4,
"regularMarketChange": -0.05000019,
"regularMarketChangePercent": -1.0000038,
"regularMarketTime": 1648141256,
"regularMarketPrice": 4.95,
"regularMarketDayHigh": 4.95,
"regularMarketDayRange": "4.95 - 4.95",
"regularMarketDayLow": 4.95,
"regularMarketVolume": 604,
"regularMarketPreviousClose": 5,
"displayName": "Tandy Leather Factory",
"symbol": "TLFA"
},
{
"language": "en-US",
"region": "US",
"quoteType": "EQUITY",
"typeDisp": "Equity",
"quoteSourceName": "Nasdaq Real Time Price",
"triggerable": true,
"customPriceAlertConfidence": "HIGH",
"currency": "USD",
"tradeable": false,
"exchange": "NCM",
"shortName": "ChromaDex Corporation",
"longName": "ChromaDex Corporation",
"messageBoardId": "finmb_5034211",
"exchangeTimezoneName": "America/New_York",
"exchangeTimezoneShortName": "EDT",
"gmtOffSetMilliseconds": -14400000,
"market": "us_market",
"esgPopulated": false,
"marketState": "REGULAR",
"fullExchangeName": "NasdaqCM",
"financialCurrency": "USD",
"regularMarketOpen": 2.52,
"averageDailyVolume3Month": 421352,
"averageDailyVolume10Day": 520790,
"fiftyTwoWeekLowChange": 0.5400001,
"fiftyTwoWeekLowChangePercent": 0.2797928,
"fiftyTwoWeekRange": "1.93 - 11.2",
"fiftyTwoWeekHighChange": -8.73,
"fiftyTwoWeekHighChangePercent": -0.77946424,
"fiftyTwoWeekLow": 1.93,
"fiftyTwoWeekHigh": 11.2,
"earningsTimestamp": 1646841720,
"earningsTimestampStart": 1651694400,
"earningsTimestampEnd": 1652126400,
"trailingAnnualDividendRate": 0,
"trailingAnnualDividendYield": 0,
"epsTrailingTwelveMonths": -0.404,
"epsForward": -0.15,
"epsCurrentYear": -0.29,
"priceEpsCurrentYear": -8.5172415,
"sharesOutstanding": 68126000,
"bookValue": 0.464,
"fiftyDayAverage": 2.664,
"fiftyDayAverageChange": -0.194,
"fiftyDayAverageChangePercent": -0.072822824,
"twoHundredDayAverage": 5.90605,
"twoHundredDayAverageChange": -3.4360502,
"twoHundredDayAverageChangePercent": -0.5817848,
"marketCap": 168724224,
"forwardPE": -16.466665,
"priceToBook": 5.323276,
"sourceInterval": 15,
"exchangeDataDelayedBy": 0,
"pageViewGrowthWeekly": 0.02642558,
"averageAnalystRating": "1.7 - Buy",
"firstTradeDateMilliseconds": 1214400600000,
"priceHint": 4,
"regularMarketChange": -0.03999996,
"regularMarketChangePercent": -1.5936241,
"regularMarketTime": 1648145420,
"regularMarketPrice": 2.47,
"regularMarketDayHigh": 2.99,
"regularMarketDayRange": "2.45 - 2.99",
"regularMarketDayLow": 2.45,
"regularMarketVolume": 221155,
"regularMarketPreviousClose": 2.51,
"bid": 2.46,
"ask": 2.47,
"bidSize": 9,
"askSize": 10,
"displayName": "ChromaDex",
"symbol": "CDXC"
}
],
"error": null
}
}
Here is my VBA code
Sub RequestURL()
Dim i As Integer
Dim rstring As String
Dim item As Object
Dim lrow As Integer: lrow = Range("A10000").End(xlUp).Row
rstring = "https://yfapi.net/v6/finance/quote?region=US&lang=en&symbols="
For i = 2 To lrow
rstring = rstring & Tsheet.Range("A" & i).Value & "%2C"
Next i
rstring = Left(rstring, Len(rstring) - 3)
Dim request As New WinHttpRequest
Dim key As String
key = "mykey"
request.Open "get", rstring
request.SetRequestHeader "X-API-Key", key
request.Send
If request.Status <> 200 Then
MsgBox request.ResponseText
Else
MsgBox request.ResponseText
End If
' To access Data
Dim reply As Object
Set reply = JsonConverter.ParseJson(request.ResponseText)
Dim price As Collection
Set price = reply("result")
Dim result As Dictionary
For Each result In price
Debug.Print result("regularMarketPreviousClose")
Next
End Sub
JSON uses name value pairs format.
Curly brackets hold objects and square ones hold array.
Result is an object itself and holds array of objects in it.
Since , it is inside quoteResponse. You must address it first and then the result inside it.
Set price = reply("quoteResponse")("result")
I am trying to parse a JSON response. I cannot use the VBA-JSON library. I need to check to see if a nested array is empty or null. I keep getting this error:
Example JSON:
{
"gardenAssets": [],
"gardenAssetsAlertCount": 0,
"gardenAssetsCount": 0,
"gardenAssetsErrorCount": 0,
"locationsSummaries": [
{
"locations": [
{
"auditOrder": "102",
"code": "POT 102",
"name": "POT 102",
"type": "ProcessingLocation",
"gardenAssets": [
{
"annotation": "Pallets",
"broker": {
"code": "TMTO",
"isOwner": null,
"name": null
},
"datetimeOfArrivalIngarden": 1622754283.937,
"id": "crusaf",
"isSealable": true,
"load": null,
"mastergardenCode": null,
"name": null,
"owner": {
"code": "SUN",
"isOwner": null,
"name": null
}
}
]
},
{
"auditOrder": "103",
"code": "POT 103",
"description": "POT 103",
"id": "110746",
"name": "POT 103",
"type": "ProcessingLocation",
"gardenAssets": []
},
{
"auditOrder": "104",
"code": "POT 104",
"name": "POT 104",
"gardenAssets": [
{
"annotation": "Soil",
"broker": {
"code": "OTHR",
"isOwner": null,
"name": null
},
"datetimeOfArrivalIngarden": 1622571699.767,
"id": "arserana",
"isSealable": true,
"load": null,
"mastergardenCode": null,
"name": null,
"owner": {
"code": "WTR",
"isOwner": null,
"name": null
}
}
]
},
{
"auditOrder": "111",
"code": "POT 111",
"name": "POT 111",
"type": "ProcessingLocation",
"gardenAssets": [
{
"annotation": null,
"broker": {
"code": "CLD",
"isOwner": null,
"name": null
},
"datetimeOfArrivalIngarden": 1622746446.932,
"id": "Bacrea",
"isSealable": true,
"load": null,
"mastergardenCode": null,
"name": null,
"owner": {
"code": "ICE",
"isOwner": null,
"name": null
},
"status": "EMPTY",
"type": "JUNK",
"unavailable": false,
"visitId": "1003768526"
}
]
}
],
"logingarden": true,
"mastergardenCodes": [],
"gardenCode": "FUN5"
}
],
"offsitegardens": [],
"gardenAssetsInTransit": []}
Code:
Option Explicit
Dim S as Object, k, Ks as Object
Set S = CreateObject("ScriptControl")
S.Language = "JScript"
S.addcode "function k(a){var k=[];for(var b in a){k.push('[\'' + b + '\']');}return k;}"
S.Eval ("var J = " & http.ResponseText)
S.Eval ("var L = J.locationsSummaries['0'].locations")
Set Ks = S.Eval("J.locationsSummaries['0'].locations")
For Each K In Ks
If Not IsNull(S.Eval(K.gardenAssets)) = True Then
Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1) = "Assets"
End If
Next K
I need to pull different information out of the JSON depending on if there are any gardenAssets. But I can't seem to check to see if the array is empty or not.
You can use the length property in JScript.
Dim S As Object
Dim n As Integer, i As Integer, r As Long
r = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
Set S = CreateObject("ScriptControl")
With S
.Language = "JScript"
.eval "var J = " & http.ResponseText
.eval "var A = J.locationsSummaries['0'].locations"
For n = 1 To S.eval("A.length")
.eval "var L = A[" & n - 1 & "]"
For i = 1 To .eval("L.gardenAssets.length")
Sheet1.Cells(r, 1) = .eval("L.code")
Sheet1.Cells(r, 2) = .eval("L.gardenAssets[" & i - 1 & "].id")
r = r + 1
Next
Next
End With
The example JSON isn't valid. The last member of an object or the last element of an array shouldn't have a comma after it. So where you have:
"broker": {
"code": "TMTO",
"isOwner": null,
"name": null,
}
There shouldn't be a comma after "name": null - there are multiple other errors like this in the example JSON.
You can use an online JSON validator (like this one) to detect these errors. You would ideally want to fix the system that is generating this invalid JSON rather than trying to correct the issues yourself during processing
This question already has answers here:
When the error reappears error handling does not work
(3 answers)
Closed 3 years ago.
I have a json code which looks like the following:
{
"gstin": "32AAOFV7699A1ZR",
"fp": "012019",
"filing_typ": "M",
"gt": 0,
"cur_gt": 0,
"b2b": [
{
"cname": null,
"inv": [
{
"val": 17136,
"itms": [
{
"num": 1,
"itm_det": {
"csamt": 0,
"samt": 408,
"rt": 5,
"txval": 160,
"camt": 408
}
}
],
"inv_typ": "R",
"flag": "U",
"updby": "S",
"idt": "14-02019",
"rchrg": "N",
"inum": "VTR/142",
}
]
},
{
"cfs": "N",
"cname": null,
"inv": [
{
"val": 4745,
"itms": [
{
"num": 1,
}
],
"inv_typ": "R",
"idt": "31-2019",
"rchrg": "N",
"inum": "BLM/35",
},
{
"val": 3631,
"itms": [
{
"num": 1,
"itm_det": {
"csamt": 0,
"samt": 824.53,
"rt": 5,
"txval": 32982,
"camt": 824.53
}
}
],
"inv_typ": "R",
"flag": "U",
"idt": "12019",
"inum": "BLM/1",
}
]
}
{
"cname": "as",
"inv": [
{
"val": 16,
"itms": [
{
"num": 1,
"itm_det": {
"camt": 408
}
}
],
"inv_typ": "R",
"flag": "U",
"updby": "S",
"idt": "142019",
"rchrg": "N",
"inum": "VT2",
}
]
},
],
"cnr":"ja"
}
It looks fine until the value of a is 3 and i is 2
Where I try to access the value of next b2b.
What I have as in vba is
Sub Jsonread()
Dim FSO As New FileSystemObject
Dim JsonTS As TextStream
Dim jsonText As String
Dim jsonObject As Object
Dim item As Variant
Set JsonTS = FSO.OpenTextFile("C:\Users\ret\Write.json", ForReading)
jsonText = JsonTS.ReadAll
JsonTS.Close
Dim i As Long
Set jsonObject = JsonConverter.ParseJson(jsonText)
i = 1
Cells(1, 2).Value = jsonObject("fp")
Dim a As Long
Dim rower As Long 'Just a row selector
rower = 1
Do While i > 0
a = 1
Do While a > 0
rower = rower + 1
On Error GoTo Mainloop
Cells(rower, 1).Value = jsonObject("b2b")(i)("inv")(a)("idt")
On Error GoTo Mainloop
Cells(rower, 2).Value = jsonObject("b2b")(i)("inv")(a)("inum")
On Error GoTo Mainloop
Cells(rower, 3).Value = jsonObject("b2b")(i)("inv")(a)("val")
a = a + 1
Loop
Mainloop:
rower = rower + 1
i = i + 1
Loop
outside:
End Sub
At first when i is 1 and a is 2 that is an runtime error 9 but the On Error Goto handles it. but after i=2 and a=3 there is no value in json and the on error goto should have handle it, but it doesn't. I have tried placing the On Error Goto in different places of the code, it simply doesn't ignore the error and run i=3 and a=1. Why is it so?
Add a label under outside, call it ErrHandler, and make it Resume to the MainLoop label:
outside:
Exit Sub
ErrHandler:
Resume Mainloop
End Sub
Then change your On Error statements to jump to ErrHandler, and now all executable code in the "happy path" never gets to run while in an error state, and all executable code in the "error path" (i.e. the ErrHandler subroutine) now only get to run while in an error state: execution paths are sorted out and de-tangled, and everything should "just work" now.
I'm using VBA-web (https://vba-tools.github.io/VBA-Web/) to access trello api, to get cards in a list
My function looks like that:
Public Function CountCardsinList(ListId As String) As Integer
WebHelpers.EnableLogging = False
Dim TrelloClient As New WebClient
TrelloClient.BaseUrl = "https://api.trello.com/1/"
Dim Request As New WebRequest
Request.Format = WebFormat.Json
Request.ResponseFormat = Json
Request.Resource = "lists/{ListId}/cards"
Request.AddUrlSegment "ListId", ListId
Request.AddQuerystringParam "key", TrelloAPIKey
Request.AddQuerystringParam "token", TrelloAPIToken
Request.AddQuerystringParam "filter", "open"
Dim Response As WebResponse
Set Response = TrelloClient.Execute(Request)
If Response.StatusCode = WebStatusCode.Ok Then
Debug.Print Response.Content '
'Response.Data("idList").Count
Debug.Print "CountCardsinList =>>> " & Response.Content
CountCardsinList = Response.Data("idList").Count
Else
MsgBox Response.StatusDescription, vbCritical, "Error " & Response.StatusCode
CountCardsinList = ""
End If
Debug.Print "CountCardsinList =>>> " & Response.Content
'Set CountCardsinList = Request
End Function
I receive correct JSON reply from the api:
[{
"id": "584e798dd570ae187b293e5b",
"checkItemStates": null,
"closed": false,
"dateLastActivity": "2016-12-30T09:24:57.531Z",
"desc": "",
"descData": null,
"idBoard": "57873ba94794058756fa0a96",
"idList": "57873bb3a725f734089702b2",
"idMembersVoted": [],
"idShort": 90,
"idAttachmentCover": null,
"manualCoverAttachment": false,
"idLabels": ["57873ba984e677fd3683bef8"],
"name": "card name / other stuff",
"pos": 1999.9923706054688,
"shortLink": "izoqvWJk",
"badges": {
"votes": 0,
"viewingMemberVoted": false,
"subscribed": false,
"fogbugz": "",
"checkItems": 0,
"checkItemsChecked": 0,
"comments": 0,
"attachments": 0,
"description": false,
"due": "2016-12-26T11:00:00.000Z",
"dueComplete": false
},
"dueComplete": false,
"due": "2016-12-26T11:00:00.000Z",
"idChecklists": [],
"idMembers": ["54f0cc079bf18f2798dda8bd"],
"labels": [{
"id": "57873ba984e677fd3683bef8",
"idBoard": "57873ba94794058756fa0a96",
"name": "Urgent",
"color": "red",
"uses": 14
}],
"shortUrl": "https://trello.com/c/vfvfdvdfv",
"subscribed": false,
"url": "https://trello.com/c/fdvfdvdfv/cfvdfv"
},
{
"id": "5832c2fa7f55fe5637d972ea",
"checkItemStates": null,
"closed": false,
"dateLastActivity": "2016-12-30T09:25:09.222Z",
"desc": "",
"descData": null,
"idBoard": "57873ba94794058756fa0a96",
"idList": "57873bb3a725f734089702b2",
"idMembersVoted": [],
"idShort": 80,
"idAttachmentCover": null,
"manualCoverAttachment": false,
"idLabels": ["57873ba984e677fd3683bef6"],
"name": "other card name",
"pos": 2023.9922790527344,
"shortLink": "XhUPgcsD",
"badges": {
"votes": 0,
"viewingMemberVoted": false,
"subscribed": false,
"fogbugz": "",
"checkItems": 0,
"checkItemsChecked": 0,
"comments": 0,
"attachments": 0,
"description": false,
"due": "2016-12-30T15:00:00.000Z",
"dueComplete": false
},
"dueComplete": false,
"due": "2016-12-30T15:00:00.000Z",
"idChecklists": [],
"idMembers": ["54fdbe1a8ecdf184596c7c07"],
"labels": [{
"id": "57873ba984e677fd3683bef6",
"idBoard": "57873ba94794058756fa0a96",
"name": "Medium",
"color": "yellow",
"uses": 1
}],
"shortUrl": "https://trello.com/c/XhdfvdfvUPgcsD",
"subscribed": false,
"url": "https://trello.com/c/XhUPgcsfdvdffvD/
"
But I cannot correctly count idList -> and I'm trying to get number of cards in a list, by using Response.Data("idList").Count
Any information how to do it proper way? or which is the best way to parse JSON data?
General:
Your JSON isn't properly closed. I added }] to the end to close and placed in cell A1 of activesheet (as I don't have the API info). I then read that in from the cell as if it were response text.
Process:
I then used JSONConverter to parse this string from the sheet. This requires you to also add a reference to Microsoft Scripting Runtime via VBE > Tools > References.
The returned object is a collection of dictionaries. I test each dictionary for the existence of an idList key and if present add 1 to the variable itemCount, which keeps track of how many idLists there are.
Code:
Public Sub GetInfoFromSheet()
Dim jsonStr As String, item As Object, json As Object, itemCount As Long
jsonStr = [A1]
Set json = JsonConverter.ParseJson(jsonStr)
For Each item In json 'collection
If item.Exists("idList") Then itemCount = itemCount + 1
Next item
Debug.Print "idList count: " & itemCount
End Sub
Hey I need help in deserializing this:
{
"success": true,
"rgInventory": {
"2722309060": {
"id": "2722309060",
"classid": "939801430",
"instanceid": "188530139",
"amount": "1",
"pos": 1
},
"2722173409": {
"id": "2722173409",
"classid": "937254203",
"instanceid": "188530139",
"amount": "1",
"pos": 2
},
"2721759518": {
"id": "2721759518",
"classid": "720293857",
"instanceid": "188530139",
"amount": "1",
"pos": 3
},
"2721748390": {
"id": "2721748390",
"classid": "310777652",
"instanceid": "480085569",
"amount": "1",
"pos": 4
}
}
}
at the end it should look like:
2722309060#2722173409#2721759518#2721748390
Dim result = JsonConvert.DeserializeObject(jsonstring) 'deserialize it
Dim tempfo As String = result("rgInventory").ToString 'get rgInventory
Console.WriteLine(tempfo)
how i can deserialize all 'id's?
The json contains a Dictionary of items, the IDs you want are the keys. If you deserialized it, you could get them from the Dictionary. Otherwise, you can use JParse and linq to get them:
Dim jstr As String = ...
' parse the json
Dim js As JObject = JObject.Parse(jstr)
' extract the inventory items
Dim ji As JObject = JObject.Parse(js("rgInventory").ToString)
' get and store the keys
Dim theIds As List(Of String) = ji.Properties.Select(Function(k) k.Name).ToList()
I suspect that when "success" is false that the resulting items list will be empty. Test that it works:
For Each s As String In theIds
Console.WriteLine(s)
Next
Result:
2722309060
2722173409
2721759518
2721748390