I am trying to write a debugger visualizer for a TJSONObject or TJSONValue. Most of the visualizer works for me well. The problem I am facing is getting a reference to a TJSONObject, or at least the tostring () value for a TJSONObject.
According to the samples I saw, as well as a good post by Jeremy Sever at http://edn.embarcadero.com/article/40268 , I should get what I need the Show method of my implementation of IOTADebuggerVisualizerExternalViewer. In particular, from the string parameters Expression, TypeName and EvalResult.
From what I understand, an expression is the name of the variable to be checked (rendered), TypeName is the name of the variable's class, and EvalResult is the default string representation of the variable.
For a simple test, I placed TMemo on a TFrame descendant. From the IOTADebuggerVisualizerExternalViewer.Show method, I call the ShowJSONObject method of my TFrame, to which I pass Expression, TypeName and EvalResult. The corresponding code is displayed here:
function TDebuggerJSONVisualizer.Show(const Expression, TypeName, EvalResult: string; SuggestedLeft, SuggestedTop: Integer): IOTADebuggerVisualizerExternalViewerUpdater; var AForm: TCustomForm; AFrame: TJSONViewerFrame; VisDockForm: INTACustomDockableForm; begin VisDockForm := TJSONVisualizerForm.Create(Expression) as INTACustomDockableForm; AForm := (BorlandIDEServices as INTAServices).CreateDockableForm(VisDockForm); AForm.Left := SuggestedLeft; AForm.Top := SuggestedTop; (VisDockForm as IFrameFormHelper).SetForm(AForm); AFrame := (VisDockForm as IFrameFormHelper).GetFrame as TJSONViewerFrame; AFrame.ShowJSONObject(Expression, TypeName, EvalResult); Result := AFrame as IOTADebuggerVisualizerExternalViewerUpdater; end; { TStringListViewerFrame } procedure TJSONViewerFrame.ShowJSONObject(const Expression, TypeName, EvalResult: string); begin Memo1.Lines.Add(Expression); Memo1.Lines.Add(TypeName); Memo1.Lines.Add(EvalResult); end;
As you can see, at this moment I am only trying to display the values โโof these three parameters from my ShowJSONObject method.
Here is a simple TJSONObject that I tried to render using the visualizer:
var jo: TJSONObject; begin jo := TJSONObject.Create; jo.AddPair('one', 'one'); jo.AddPair('two', TJSONNumber.Create(1));
The result is as follows:

I was hoping EvalResult would return a tostring TJSONObject view, but it returned uninformative (), which is the same as what you see by default in the local variables window.
How to get either the tostring representation of the TJSONObject for which the visualizer was called, or the handle of the actual object, so I can deconstruct and display its value?