exten recursive finding
This commit is contained in:
parent
42bd90fb7b
commit
d4a3bf6f44
32
main.nim
32
main.nim
@ -10,24 +10,32 @@ var client = newHttpClient()
|
|||||||
var html: string
|
var html: string
|
||||||
#var node: XmlNode
|
#var node: XmlNode
|
||||||
|
|
||||||
proc do_another_loop( node : JsonNode, level : int, searchString : string = "") =
|
proc do_another_loop( node : JsonNode, level : int, searchString : string = "",path :string = "H") =
|
||||||
if node.len() > 0:
|
if node.len() > 0:
|
||||||
for a in node.keys:
|
for a in node.keys:
|
||||||
if node.kind == JObject:
|
if node.kind == JObject:
|
||||||
#for i in 0 .. level:
|
#for i in 0 .. level:
|
||||||
if searchString == "" or contains($node[a],searchString):
|
if searchString == "" or a.contains(searchString):
|
||||||
stdout.write ">"
|
#for x in 0..level:
|
||||||
stdout.write a
|
# stdout.write " "
|
||||||
|
stdout.write "|", path & "-" & a
|
||||||
if node[a].kind == JObject:
|
if node[a].kind == JObject:
|
||||||
do_another_loop(node[a],level+1,searchString)
|
stdout.write("\n")
|
||||||
|
do_another_loop(node[a],level+1,searchString,path & "-" & a)
|
||||||
else:
|
else:
|
||||||
if searchString == "" or contains($node[a],searchString):
|
if searchString == "" or a.contains(searchString):
|
||||||
stdout.write " [", node[a].kind, "]\n"
|
stdout.write " [", node[a].kind, "]"
|
||||||
|
stdout.write("\n")
|
||||||
if node[a].kind == JArray:
|
if node[a].kind == JArray:
|
||||||
if searchString == "" or contains($node[a],searchString):
|
if searchString == "" or a.contains(searchString):
|
||||||
echo node[a]
|
echo "Array Elements: ", node[a].getElems()
|
||||||
else:
|
echo "Array Length", node[a].len()
|
||||||
echo "yyyyyyyy"
|
echo "WWWWWWWWWWWWWWW"
|
||||||
|
for b in node[a]:
|
||||||
|
echo b
|
||||||
|
do_another_loop(b,level,searchString,path & "-" & a)
|
||||||
|
|
||||||
|
#stdout.write "\n"
|
||||||
else:
|
else:
|
||||||
echo "\n--------"
|
echo "\n--------"
|
||||||
|
|
||||||
@ -60,7 +68,7 @@ try:
|
|||||||
#echo "JSON Node:", jsonNode
|
#echo "JSON Node:", jsonNode
|
||||||
#echo "node fields: ",jsonNode["props"]["pageProps"]["pageTitle"].getStr()
|
#echo "node fields: ",jsonNode["props"]["pageProps"]["pageTitle"].getStr()
|
||||||
let field = jsonNode.getFields()
|
let field = jsonNode.getFields()
|
||||||
do_another_loop(jsonNode,0,"resultitems")
|
do_another_loop(jsonNode,0,searchString = "resultItems")
|
||||||
|
|
||||||
#echo "resultitem", jsonNode["resultItems"]
|
#echo "resultitem", jsonNode["resultItems"]
|
||||||
# for a in jsonNode.keys:
|
# for a in jsonNode.keys:
|
||||||
|
Loading…
Reference in New Issue
Block a user