Quantcast
Channel: Embarcadero Community - Embarcadero Community
Viewing all articles
Browse latest Browse all 1888

JSon, streams and strings

$
0
0

I have an object (TFoo = class, MyFoo) the has a string field (public FRICHEDIT) to store the contents of a TStringStream.DataString.

I have a TMS FNC TRichEditor where I can save the contents to a steam, in this case a MyStringStream: TStringStream. I then set FRICHEDIT (via prop) to the TStringStream.DataString;

I populate other MyFoo fields via properties and members, and set a MyStringList.Text to TJson.ObjectToJsonString(MyFoo), followed by a SaveToFile. Works great. Inspect the file with Notepad++, all looks as expected, including all public fields.

To restore from file, I use MyStringList.LoadFromFile, followed by TJSON.JsonToObject(MyStringList.Text). Object is created properly, FRICHEDIT looks ok and is equal to the last saved FRICHEDIT string (i.e., unchanged).

When I try to do MyStringStream.WriteString(FRICHEDIT), I get an AV error. I think this is related to an encoding problem, but I cannot find it with debug.

The intention is to use the TRichEditor.LoadFromStream(MyStringStream) to restore the rte (rtf) contents).

I have also sent a support request to TMS to see if there is a better way to do this.

 

I can include a coding example or snippet is necessary. Thanks.


Viewing all articles
Browse latest Browse all 1888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>