I've just started to move parts of my app over to a distributed model, and plan to send data to the clients in JSON format. While still playing with the techniques, I created a very simple test to see the generated JSON.
Basically, I load an object from the database using Aurelius, then use a DataSnap serializer to convert it to JSON which is then displayed in a memo.
However, the JsonValue.Value is empty. I single stepped through the conversion, and it appears to be picking up my field names and adding them to the output, but I see nothing. I tried the identical test using the ObjectToJson serializer in morMot, and that worked fine.
Am I missing something dumb here? The code couldn't be much simpler.
procedure TForm8.btnToJsonClick(Sender: TObject);
var
sample : TSample;
om : TObjectManager;
Serializer : TDataSnapJsonSerializer;
JsonValue : TJsonValue;
begin
om := AvalonStorage.CreateObjectManager;
Serializer := TDataSnapJsonSerializer.Create;
try
sample := AvalonStorage.LoadSample(om, 223442); // sample holds valid data
JsonValue := Serializer.ToJson(sample);
try
memJson.Lines.Text := JsonValue.Value;
finally
JsonValue.Free;
end;
finally
om.Free;
Serializer.Free;
end;
end;