Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread TReader/TWriter serialisation name maps
Tue, Apr 26 2016 7:54 AMPermanent Link

Matthew Jones

I have some JSON with names like "qty" and "mkup" to keep things small,
since they are repeated hundreds of times in a JSON object (child
arrays). Obviously I would like to have my EWB code use names like
"Quantity" and "Markup". Is there anything built in to support this?

My ideal would be to have an event that the TPersistent streamer calls
to map from one name to another, so it would pass in "Quantity" and get
back "qty". And probably vice versa for reading.

But it also looks like I could cheat, and use the public properties for
nice names, and the published properties for the streaming names. Is
that going to be stable if I have two properties referring to the same
object? It seems to compile okay.


Anyone else done anything like this?

private
   m_szHumanDescription : String;

public
   property HumanDescriptionTXT : String
        read m_szHumanDescription write m_szHumanDescription;

published
   property Desc : String
        read m_szHumanDescription write m_szHumanDescription;


--

Matthew Jones
Tue, Apr 26 2016 9:22 AMPermanent Link

Matthew Jones

Matthew Jones wrote:

>  use the public properties for
> nice names, and the published properties for the streaming names

This appears to work okay.

--

Matthew Jones
Wed, Apr 27 2016 12:41 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< But it also looks like I could cheat, and use the public properties for nice names, and the published properties for the streaming names. Is that going to be stable if I have two properties referring to the same object? It seems to compile okay. >>

Yes, that will work fine and doesn't result in any additional code overhead.

Tim Young
Elevate Software
www.elevatesoft.com
Image