@startuml !$myjson = { "root" : [{ "fruits": [ { "name": "apple", "colorId": "1" }, { "name": "pear", "colorId": "2" }, { "name": "pineapple", "colorId": "3" } ] }, { "colors": [ { "id": "1", "name": "red" }, { "id": "2", "name": "green" }, { "id": "3", "name": "yellow" } ] }] } !procedure process_json($stem, $json) !if %get_json_type($json) == "array" map %string($stem) { } !$j=0 !foreach $node in $json process_json(%string($stem+"."+$j), $node) $stem --> %string($stem+"."+$j) !$j=$j+1 !endfor !elseif %get_json_type($json) == "object" ' parse for map map $stem { !foreach $key in %get_json_keys($json) !$value = $json[$key] !if %get_json_type($value) != "array" $key => $value !endif !endfor } ' parse again for recursions into sub-arrays !foreach $key in %get_json_keys($json) !$key2 = $key /' foreach uses a global $key, so we need to move to a local $key2 so we can recurse '/ !$value = $json[$key2] /' %get_json_type only takes standard variables, so move to $value '/ !if %get_json_type($value) == "array" process_json(%string($stem+"."+$key2), $value) $stem ---> %string($stem+"."+$key2) !endif !endfor !else ' nothing to do for string/number/boolean/null !endif !endprocedure skinparam labelFontSize 7 label A [ process_json("root", $myjson.root) root.0.fruits.0::apple -> root.1.colors.0::red ] label B [ {{ set namespaceSeparator none process_json("root", $myjson.root) root.0.fruits.0::apple -> root.1.colors.0::red }} ] @enduml
Decode URL
Submit
amiga
aws-orange
black-knight
bluegray
blueprint
cerulean-outline
cerulean
crt-amber
crt-green
cyborg-outline
cyborg
hacker
lightgray
mars
materia-outline
materia
metal
mimeograph
minty
plain
reddress-darkblue
reddress-darkgreen
reddress-darkorange
reddress-darkred
reddress-lightblue
reddress-lightgreen
reddress-lightorange
reddress-lightred
sandstone
silver
sketchy-outline
sketchy
spacelab
spacelab-white
superhero-outline
superhero
toy
united
vibrant
Pure Javascript
PNG
SVG
ASCII Art