Guest User

Untitled

a guest
Jun 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. {"result": [
  2. {"name":"??? ?????",
  3. "type":2,
  4. "latlong":"26.547745,82.431729"},
  5. {"name":"????",
  6. "type":2,
  7. "latlong":"20.169723,85.415944"},
  8. {"name":"??????",
  9. "type":2,
  10. "latlong":"20.674808,76.882579"},
  11. {"name":"???????",
  12. "type":2,
  13. "latlong":"20.664026,76.542137"}
  14. ]}
  15.  
  16. Set json = JsonConverter.ParseJson(strJSON)("result")
  17.  
  18. For Each i In json
  19. Set dict = i
  20. 'Other code
  21. Next i
  22.  
  23. Select Case key2
  24. Case "name"
  25. .Cells(counter, 1) = dict(key2)
  26. Case "type"
  27. .Cells(counter, 2) = dict(key2)
  28. Case "latlong"
  29. .Cells(counter, 3) = dict(key2)
  30. End Select
  31.  
  32. Option Explicit
  33. Public Sub GetInfo()
  34. Dim strURL As String, strJSON As String
  35. Dim http As Object
  36. Dim json As Object, item As Long
  37.  
  38. Application.ScreenUpdating = False
  39. strURL = "http://www.vehicletrack.biz/api/xlsmaster?usr=rahul&pwd=togodeamo&type=2"
  40.  
  41. Set http = CreateObject("MSXML2.XMLHTTP")
  42. http.Open "GET", strURL, False
  43. http.send
  44. strJSON = http.responseText
  45. Set json = JsonConverter.ParseJson(strJSON)("result") 'dictionary one key of "Result" which is a collection of dictionaries when accessed
  46.  
  47. Dim i As Object, dict As Object, key2 As Variant, counter As Long
  48. counter = 4
  49. For Each i In json
  50. Set dict = i
  51. For Each key2 In dict.Keys
  52. With ActiveSheet
  53. Select Case key2
  54. Case "name"
  55. .Cells(counter, 1) = dict(key2)
  56. Case "type"
  57. .Cells(counter, 2) = dict(key2)
  58. Case "latlong"
  59. .Cells(counter, 3) = dict(key2)
  60. End Select
  61. End With
  62. Next key2
  63. counter = counter + 1
  64. Next i
  65. Application.ScreenUpdating = True
  66. End Sub
Add Comment
Please, Sign In to add comment