I need to diagnose some object hierarchy issues in a webconnect project
Does anyone have some neat code to recursively go through an object and write out the property names and values to something I can review?
Michael -
In wwUtils, there is a PropertyDump()
function which will write out the key/value pairs for a single object, although that function is not recursive.
However, the wwUtils::CopyObject()
function is recursive. You should be able to combine & adapt the two functions to get exactly what you want.
- Mike McDonald
Software Design of Kentucky
Nice! Thanks a ton, Mike.
I use JSON serialization for this.
DO wwJsonSerializer
_clipText = JsonSerialize(loObject, .T.) && formatted
Then open in VS Code or other JSON capable editor.
It'll do the hierarchy. You can get into the weeds with nested object references though so careful with that.
--- edit ---
Come to think about it you can use ShowText()
to display the JSON too:
DO wwJsonSerializer
DO wwUtils
lcJson = JsonSerialize(loObject, .T.) && formatted
ShowText(lcJson,"c:\temp\output.json") && opens in configured editor (VS Code for me)
+++ Rick ---