excel - How to get, ("fields") to Work in VBA-JSON -


summary

i trying access deep levels of nested json comes api working @ moment. using vba-json through process has been pretty easy, i've ran little road block. part, i've got library work properly, error anytime try grab item nested in json response (further 2 json levels). going submit post, , i'll go , gather of error codes getting. off top of head, know run-time error '13' when try use code below doesn't work. think (could wrong) smart enough understand type mismatch error, don't know how fix it.

this works

for = 1 20     activesheet.cells(i + 1, 5) = json("issues")(i)("key")     activesheet.cells(i + 1, 6) = json("issues")(i)("id") next 

doesn't work

for = 1 20     activesheet.cells(i + 1, 7) = json("fields")(i)("summary") next 

none of these worked either

activesheet.cells(i + 1, 7) = json("fields")(i)("summary") activesheet.cells(i + 1, 7) = json("fields")("summary") activesheet.cells(i + 1, 7) = json("issues")("fields")("summary")  activesheet.cells(i + 1, 7) = json("fields")("assignee")(i)("name") activesheet.cells(i + 1, 7) = json("issues")("fields")("assignee")(i)("name") 

updated json

i edited json comes privacy reasons (obviously).

{   "expand": "schema,names",   "startat": 0,   "maxresults": 50,   "total": 28,   "issues": [ {     "expand": "",     "id": "94581",     "self": "",     "key": "",     "fields": {       , "assignee": {}       , "status": {}       , "votes": {}       , "summary": ""       ,       , "issuetype": {}       , "timespent": null,     }   }   ,   {}   ,   {}   ,   {}   ] } 

according data structure, code should looking @ right place, right?

thoughts? :)


ps: sorry if jargon off, i'm developer hobby, not job. :)

the problem

nested arrays problem. 2'nd level of json items not arrays, while, "fields" was.

to solve problem, need add (i + 1) code.

working code example

'''''''' ' loop ' ''''''''  = 1 20     activesheet.cells(i + 1, 5) = json("issues")(i)("key")     activesheet.cells(i + 1, 6) = json("issues")(i)("id")     activesheet.cells(i + 1, 7) = json("issues")(i + 1)("fields")("summary")     activesheet.cells(i + 1, 8) = json("issues")(i + 1)("fields")("watches")("watchcount")     activesheet.cells(i + 1, 9) = json("issues")(i + 1)("fields")("workratio") next 

update :(

so, got of code setup run report, , working, , randomly stops (i watched on line 16 or so) , gives me type mismatch error.

how rows 1-15 working, , there type mismatch error?

lol...

debugging now...

update 2 :)

simple mix code structure, there wasn't problem , solution posted below works correctly.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -