krijnsent / crypto_vba

An Excel/VBA project to communicate with various cryptocurrency exchanges APIs
MIT License
155 stars 54 forks source link

ArrayTable() - JSON with empty levels #2

Closed theMoe closed 6 years ago

theMoe commented 6 years ago

Hi,

you did a great job! Thanks for this! I just got one problem in function

Function ArrayTable(ArrIn As Variant, Optional ReturnHeader As Boolean = True) As Variant

in module ModJSON.

I receive this JSON: In the browser it looks like:{"success":false,"message":"APISIGN_NOT_PROVIDED","result":null} In VBA it looks like: {"success":true,"message":"","result":[]}

In the function ArrayTable() at position:

Idx = Application.Match(ArrIn(3, rw), TblHeaders.keys, 0)
  If ReturnHeader = True Then
  ResArr(Idx, 1) = ArrIn(3, rw)
End If

Idx gets the value "Error 2042" and then ResArr(Idx, 1) = ArrIn(3, rw) does not work. The value of ArrIn(4,4) is 0. Can we use this information to skip "result"?

TblHeaders counts only 2 values "success" and "message". I thought about continue the for-loop, but I am not sure.

Maybe you have an idea.

Bye

Moe

krijnsent commented 6 years ago

Hi Moe, thanks for your feedback and providing the example, I will look into this issue! It's part of "better error handling" that's already on my to-do list. But as most VBA developers, I'm not that big on error handling ;). Cheers, Koen

krijnsent commented 6 years ago

Hi Moe, hope you can check whether your issue is solved like this?

theMoe commented 6 years ago

Hi Koen, thanks! I will check it. Did you fix just this issue? Or did you change anything else, too?

theMoe commented 6 years ago

I replaced just ModJSON.bas and now it works. Thanks!

krijnsent commented 6 years ago

Hi Moe, I updated some other stuff too, mainly error handling for API-connections that fail. Happy to hear it works now.