Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6815675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:50:07+00:00 2026-05-26T20:50:07+00:00

I am trying to write a debugger visualizer for a TJSONObject or a TJSONValue.

  • 0

I am trying to write a debugger visualizer for a TJSONObject or a TJSONValue. I have most of the visualizer working nicely. The problem I am having is getting a reference to the TJSONObject, or at least to the tostring() value of the TJSONObject.

According to the samples I’ve seen, as well as the nice post by Jeremy North at http://edn.embarcadero.com/article/40268, I should get what I need from the Show method of my IOTADebuggerVisualizerExternalViewer implementation. Specifically, from the Expression, TypeName, and EvalResult string parameters.

From what I understand, Expression is the name of variable being inspected (visualized), TypeName is the classname of the variable, and EvalResult is the default string representation of the variable.

For a simple test I placed a TMemo on my TFrame descendant. From the IOTADebuggerVisualizerExternalViewer.Show method I call the ShowJSONObject method of my TFrame, to which I pass Expression, TypeName, and EvalResult. The relevant code appears 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, I at this point 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 display using the visualizer:

var
 jo: TJSONObject;
begin
  jo := TJSONObject.Create;
  jo.AddPair('one', 'one');
  jo.AddPair('two', TJSONNumber.Create(1)); //a breakpoint here

The result looks like this:

A debugger visualizer under development

I was hoping that EvalResult would return the tostring representation of the TJSONObject, but it only returned the uninformative (), which is the same thing you see by default in the local variables window.

How do I get either the tostring representation of the TJSONObject for which the visualizer was invoked or a handle to the actual object, so I can deconstruct and display its value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:50:08+00:00Added an answer on May 26, 2026 at 8:50 pm

    You need to evaluate your expression (including ToString call) using this procedure (just copied from my own visualizer source so it could use some local variables that are not declared here):

    function TJSONViewerFrame.Evaluate(Expression: string): string;
    var
      CurProcess: IOTAProcess;
      CurThread: IOTAThread;
      ResultStr: array[0..4095] of Char;
      CanModify: Boolean;
      ResultAddr, ResultSize, ResultVal: LongWord;
      EvalRes: TOTAEvaluateResult;
      DebugSvcs: IOTADebuggerServices;
    begin
      begin
        Result := '';
        if Supports(BorlandIDEServices, IOTADebuggerServices, DebugSvcs) then
          CurProcess := DebugSvcs.CurrentProcess;
        if CurProcess <> nil then
        begin
          CurThread := CurProcess.CurrentThread;
          if CurThread <> nil then
          begin
            EvalRes := CurThread.Evaluate(Expression, @ResultStr, Length(ResultStr),
              CanModify, eseAll, '', ResultAddr, ResultSize, ResultVal, '', 0);
            case EvalRes of
              erOK: Result := ResultStr;
              erDeferred:
                begin
                  FCompleted := False;
                  FDeferredResult := '';
                  FDeferredError := False;
                  FNotifierIndex := CurThread.AddNotifier(Self);
                  while not FCompleted do
                    DebugSvcs.ProcessDebugEvents;
                  CurThread.RemoveNotifier(FNotifierIndex);
                  FNotifierIndex := -1;
                  if not FDeferredError then
                  begin
                    if FDeferredResult <> '' then
                      Result := FDeferredResult
                    else
                      Result := ResultStr;
                  end;
                end;
              erBusy:
                begin
                  DebugSvcs.ProcessDebugEvents;
                  Result := Evaluate(Expression);
                end;
            end;
          end;
        end;
      end;
    end;
    

    So now you can replace your Show function with something like this:

    AFrame.ShowJSONObject(Expression, TypeName, Evaluate(Expression + '.ToString'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying write a query to find records which don't have a matching record
Im trying to write something to get my images to show correctly. I have
Trying to write a trivial application, But I have stuck into one of the
I am currently trying to write an IDE with Debugger for IronPython in C#.
Trying to write a PowerShell cmdlet that will mute the sound at start, unless
Trying to write a couple of functions that will encrypt or decrypt a file
Im trying to write a single byte at a certain location in a file.
im trying to write an app that will display a list off lines from
Im trying to write a function for adding category: function addCategory() { $cname =
I'm trying to write a regex function that will identify and replace a single

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.