python - Parsing a JSON response from URL -


my requirement parse json response url response. json feed comprised of 2 list namely:

a. "ownerships" - list contain 2 main attributes

  1. nodecode
  2. parentcode

b. "nodes" - list consists of 2 attributes

  1. nodecode (nodecode primary identifier of each node)
  2. nodetype (nodetype can have values "level01", "level02" ,..., "level06")

the logic is:

  • for each nodecode value in "nodes" scan "ownerships" list related parentcode

  • come "nodes" list , search parentcode obtained in earlier step nodecode, , corresponding "nodetype"

  • repeat earlier steps till nodecodes parsed, @ end have below(all these columns single record):

    level01nodecode level02nodecode level03nodecode level04nodecode level05nodecode level06nodecode

bottom line starting lowest level(assuming level01), scan nodes , ownerhips lists, nodecode corresponding level, , keep searching based on parentcode till top levels covered.

the problem here is: a nodecode @ level01 may have parentcode can reside in 1 of levels above(it may @ level03, level04 or @ level06)

how flatten kind of data structure?

sample data structure:

{    "ownerships":[       {          "parentcode":"xx01",          "nodecode":"tt01"       },       {          "parentcode":"xx02",          "nodecode":"tt02"       }    ],    "nodes":[       {          "nodecode":"tt02",          "nodetype ":"level01"       },       {          "nodecode":"xx02",          "nodetype ":"level03"       },       {          "nodecode":"xx01",          "nodetype ":"level05"       }    ] } 


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -