FNC Grid Save/Load Settings from VCL to Web Core

Hi!
When I save FNCGrid settings in VCL and then try to load these settings in a Web Core application I get this error:

ERROR
Uncaught [object Object] | 
FMessage::Name expected FHelpContext::0 
FJSError::Error: Name expected 
FStack::Error: Name expected 
at Object.Create$1 (http://localhost:8000/SeguimientoWeb/SeguimientoWeb.js:3446:23) 
at Object.Create$2 (http://localhost:8000/SeguimientoWeb/SeguimientoWeb.js:58550:41) 
at c.$create (http://localhost:8000/SeguimientoWeb/SeguimientoWeb.js:337:19) 
at Object.DoPeek (http://localhost:8000/SeguimientoWeb/SeguimientoWeb.js:58685:36) 
at Object.NextPeek (http://localhost:8000/SeguimientoWeb/SeguimientoWeb.js:58616:97) 
at Object.HasNext (http://localhost:8000/SeguimientoWeb/SeguimientoWeb.js:59127:23) 
at Object.ReadSingleObject$1 (http://localhost:8000/SeguimientoWeb/SeguimientoWeb.js:61477:27) 
at Object.ReadObject (http://localhost:8000/SeguimientoWeb/SeguimientoWeb.js:61936:20) 
at Object.Read$1 (http://localhost:8000/SeguimientoWeb/SeguimientoWeb.js:61955:12) 
at Object.LoadSettingsFromStream (http://localhost:8000/SeguimientoWeb/SeguimientoWeb.js:62091:16)
at http://localhost:8000/SeguimientoWeb/SeguimientoWeb.js [58685:11]

It all starts where I call LoadSettingsFromStream . I save them with AppearanceOnly = True , encoding is Ok, used streams are ok, I can verify the saved contents on both platforms, but the error is always there.

I compared saved settings of a "native" Web Core FNC Grid and a VCL FNC Grid, and the only thing I noticed was that for every Font structure, VCL version has the properties Orientation,Pitch & Quality, which are not present in web version.

  "Font": {
    "$type": "TFont",
    "Charset": 1,
    "Color": "#000000",
    "Height": -12,
    "Name": "Segoe UI",
    "Orientation": 0,
    "Pitch": 0,
    "Quality": 0,
    "Size": 9,
    "IsFMX": false,
    "Style": 0
  },

May it be the problem ? I thought I could exclude them using CanSaveProperty event , but subproperties don't fire this event, only 1st level properties.

Are you using the latest version? Can you upload a test json file so we can check here what is going on?

It's not the latest version. I didn't check yet if there are breaking changes.

I made a sample.

This was saved from a web FNCGrid. I can "LoadSettings" from it:
FNCGridWebCoreSaveSettings.txt (8.2 KB)

This was saved from a VCL FNCGrid. I cannot "LoadSettings" in Web Core from this one:
FNCGridVCLSaveSettings.txt (8.8 KB)

Please download and test the latest version.

Same error with VCL & FNC latest versions.

procedure TTMSFNCReader.ReadSingleObject(AObject: TObject);
begin
  Reader.ReadBeginObject;
  if TTMSFNCPersistence.ClassTypeVariable <> '' then
  begin
    if not Reader.HasNext or (Reader.ReadName <> TTMSFNCPersistence.ClassTypeVariable) then
      raise ETMSFNCReaderException.Create('"'+TTMSFNCPersistence.ClassTypeVariable+'" property not found in Object descriptor.');
    Reader.ReadString;
  end;

This second if raises an error (the if itself, not the raise statement)

After debugging deeper, I can see it's firing
raise ENameExpected.Create;
inside of
function TTMSFNCJSONReader.DoPeek: TTMSFNCJSONState;

Astonishing !
I saw FNCJSONReader was checking for specific characters like " and } , so I decided to play with encoding. Used TEncoding.UTF8 for the GridSettings in both sides, and presto! No errors.

I was retrieving in web the same settings content I generated in VCL, so I supposed encoding was "ok".
Why did it fail?

I'm not forcing UTF8 enconding for the grid data, and LoadFromCSVStream is working with no issues, but I'll change it too, just in case.

Hi,

I was overlooking the encoding, but apparently the original compiler developers are loading streams & files with 16 byte encoding instead of 8 byte, so we enforced an encoding which loads it according to the default VCL/FMX framework encoding. So yes, you are right and I'm glad you found out that the encoding parameter is crucial for this to work. Thanks for the feedback!