Wednesday, 18 December 2019
  1 Replies
  1.7K Visits
  Subscribe
Hello!

One simple question:
I have sgcJSON class enabled with Delphi XE

I'm having trouble decrypting the JSON message from the server.

ServerMessage: {"jsonrpc":"2.0","method":"PosMessage","params":{"message":"abcabc"}}

What is the right way to get text "abcabc" from ServerMessage? Now I get "Access Violation".

MyCurrentCode:
Function PuraVastaus(Msg : String) : Boolean;
var s : String;
replobj : TsgcJSON;
apu : string;
aMsg : String;
rType : String;
oArray : IsgcObjectJSON;
begin
Memo1.clear;
s := Trim(Copy( Msg, pos('{',Msg),length(Msg) ));
replobj := TsgcJSON.Create(nil);
replobj.Read(s);
RType := replobj.Item[1].Value;
if RType = 'StatusEvent' then
begin
Memo1.lines.add('StatusEvent -- odota');
end;
if RType = 'PosMessage' then
begin
Memo1.lines.add('Posmessage:');
oArray := replobj.Node['param'];
apu := oArray.item[1].Value;
Memo1.Lines.Add(apu);
end;
end;

Regards,

Kirsi
.
Attachments (1)