While answering https://forum.plantuml.net/15326/add-edges-in-diagram-without-touching-existing-json-data, I thought about two new preprocessor built-in functions that would have been useful to make the idea more readable:
1) %get_json_type($json) returns int
- (0 - Not valid Json, optional)
- 1 - JSON array ($json starts '[')
- 2 - JSON object ($json starts '{')
- 3 - JSON other = string / number / boolean / null (or give each its own return code)
2) %get_json_keys($json_object) returns new json array containing the keys from the parameter object. For example '{"name": "Mark McGwire", "hr": 65, "avg": 0.278}' would return '["name","hr","avg"]'.
These two combined would let you write:
!if %get_json_type($myjson) == JSON_OBJECT
!foreach $key in %get_json_keys($myjson)
!if %get_json_type($myjson[$key]) == JSON_STRING
rectangle $myjson[$key]
!endif
!endfor
!endif
Just an idea.