Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.

Public Report
Report From: Delphi-BCB/Database/DataSnap    [ Add a report in this area ]  
Report #:  103562   Status: Closed
Missing overriding for TJSONTrue, TJSONFalse..
Project:  Delphi Build #:  16.0.4358.45540
Version:    16.3 Submitted By:   Tugrul HELVACI
Report Type:  Basic functionality failure Date Reported:  2/21/2012 12:13:51 AM
Severity:    Serious / Highly visible problem Last Updated: 4/15/2014 6:48:31 PM
Platform:    All platforms Internal Tracking #:   25350
Resolution: Fixed (Resolution Comments) Resolved in Build: : XE6
Duplicate of:  None
Voting and Rating
Overall Rating: (2 Total Ratings)
5.00 out of 5
Total Votes: 31
Description
Related to Report #: 103458

TJSONAncestor = class
  function Value : UnicodeString; virtual;
end;

TJSONValue = class(TJSONAncestor)
end;

TJSONTrue = class(TJSONValue)
end;

As you can see, TJSONTrue inherited from TJSONAncestor but it has no overriden Value function. So, if you want to use TJSONTrue.Value compiler calls TJSONAncestor.Value and then returns NullString. TJSONTrue and TJSONFalse must override Value function.
Steps to Reproduce:
Imagine that;

------------------
function Process(const AJSON : TJSONValue) : String;
begin
  ..
  ..
  Result := AJSON.Value;
end;

var
  json : TJSONValue;
begin
  json := TJSONTrue.Create;
  ShowMessage( Process(json) ); // It returns Null string expecting result is "true".
  json.Free;

  json := TJSONFalse.Create;
  ShowMessage( Process(json) ); // It returns Null string expecting result is "false".
  json.Free;
end;
------------------
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01