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
- nodecode
- parentcode
b. "nodes" - list consists of 2 attributes
- nodecode (nodecode primary identifier of each node)
- 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
Post a Comment