You are not logged in.
Pages: 1
Hi :)
mORMot is amazing, thanks for great work.
I have small problem. How can I save TDocVariant in a more human readable way?
I need this for settings. For example:
var
cfg: Variant;
begin
TDocVariant.New(cfg);
cfg.Host := eHost.Text;
cfg.Port := ePort.Text;
cfg.DBName := eDBName.Text;
cfg.User := eUser.Text;
cfg.Passwd := ePasswd.Text;
FileFromString(string(cfg), 'settings.json');
end;
best regards,
Maciej Izak
best regards,
Maciej Izak
Offline
Use JSONReformatToFile().
And you should better use VariantSaveJSON(cfg) instead of plain string(cfg), which makes a conversion from UTF-8 to UTF-16, then back to Ansi, which is not a good idea.
JsonReformatToFile(VariantSaveJSON(cfg),'settings.json');
So everything stays with a single RawUTF8 variable.
Offline
Thanks. Works like a charm.
best regards,
Maciej Izak
Offline
Pages: 1