Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Awkward JSON Object Property Names!
Tue, Jun 16 2015 12:23 PMPermanent Link

Mark Brooks

Slikware

Avatar

Hi Tim,

I am making extensive use of the JSON reading / writing capabilities for class published properties. This functionality is really useful and straightforward to use. It's also very fast!

However, one of the properties in the JSON that is returned from the API is called "create". I cannot seem to read this since the compiler won't let me define a published property like this:

published

 property Create: boolean read fCreate write fCreate;

It causes a compiler error further down the code inside the Create override. Do you have a neat way around this?

Thanks
Mark
Sat, Jun 20 2015 6:52 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< It causes a compiler error further down the code inside the Create
override. Do you have a neat way around this? >>

You'll have to do a custom load with this property in the
TPersistent.LoadProperty method for your class:

function TMyComponent.LoadProperty(AReader: TReader): Boolean;
var
  TempPropertyName: String;
begin
  Result:=False;
  TempPropertyName:=AReader.GetPropertyName;
  if (TempPropertyName <> '') then
     begin
     if SameText(TempPropertyName,'create') then
        //  Handle special property name here....
     else
        inherited LoadProperty(AReader);
     end;
end;

Tim Young
Elevate Software
www.elevatesoft.com
Sat, Jun 20 2015 11:43 AMPermanent Link

Mark Brooks

Slikware

Avatar

"Tim Young [Elevate Software]" wrote:

>>You'll have to do a custom load with this property in the
>>TPersistent.LoadProperty method for your class:

Of course ....... doh ...... cheers Tim
Image