#1 mORMot 1 » Brotli Compression » 2017-07-18 06:56:15

g00gle
Replies: 7

Hi Ab,
Do you have in plans add support for brotli compression algorithm ?

#2 Re: mORMot 1 » RecordLoadJSON fail case » 2016-11-15 03:21:50

And if you not agree that float can be readed from double quotes in case when we know that is it valid float then I'm not agree with you.

#3 Re: mORMot 1 » RecordLoadJSON fail case » 2016-11-15 03:05:36

2 turrican
Are you seriously ?  lol
I'm strongly recommend to you read my second post: http://synopse.info/forum/viewtopic.php … 303#p22303

#5 Re: mORMot 1 » RecordLoadJSON fail case » 2016-11-11 14:56:14

04f1690a-a838-11e6-9372-e42148d86ac9.gif


unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, SynCommons, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

   TR = packed record
    errorId          :  Integer;
    errorCode	       :  String;
    errorDescription :	String;
    status           :	String;
    solution         :
                        record
                        text : string;
                        url  : string;
                        end;
    cost             :	Double;
    ip               :	String;
    createTime       :	Integer;
    endTime	         :  Integer;
    solveCount       :	Integer;
  end;


var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
  var
 R: TR;
 s: string;
begin
  s:= '{"errorId":0,"status":"ready","solution":{"text":"failed","url":"http:\/\/69.39.239.233\/101\/147884423179984.png"},"cost":"0.001000","ip":"95.143.198.250","createTime":1478844231,"endTime":1478844239,"solveCount":"0"}';
  SynCommons.RecordLoadJSON(R, s, TypeInfo(TR) );
  Memo1.Lines.Add(    R.errorId.ToString  );
  Memo1.Lines.Add(     R.errorCode	      );
  Memo1.Lines.Add(     R.errorDescription );
  Memo1.Lines.Add(     R.status           );
  Memo1.Lines.Add(     R.solution.text    );
  Memo1.Lines.Add(     R.solution.url     );
  Memo1.Lines.Add(  'COST: ' + Format('%3.6f', [R.cost])        );
  Memo1.Lines.Add(  'IP: '  + R.ip                 );
  Memo1.Lines.Add(     R.createTime.ToString         );
  Memo1.Lines.Add(     R.endTime.ToString             );
  Memo1.Lines.Add(     R.solveCount.ToString           );
end;

#6 Re: mORMot 1 » RecordLoadJSON fail case » 2016-11-11 12:54:33

turrican
This is not JSON from my side. :\
and every thing works if change double to string,
but i think it must work without this change.

#7 mORMot 1 » RecordLoadJSON fail case » 2016-11-11 08:59:51

g00gle
Replies: 12

Here is sample, RecordLoadJSON fail at "cost"

    TR = packed record
    errorId          :  Integer;
    errorCode	       :  String;
    errorDescription :	String;
    status           :	String;
    solution         :
                        record
                        text : string;
                        url  : string;
                        end;
    cost             :	Double;
    ip               :	String;
    createTime       :	Integer;
    endTime	         :  Integer;
    solveCount       :	Integer;
  end;
....

var 
 R: TR;
 s: string;

s:= '{"errorId":0,"status":"ready","solution":{"text":"failed","url":"http:\/\/69.39.239.233\/101\/147884423179984.png"},"cost":"0.001000","ip":"95.143.198.250","createTime":1478844231,"endTime":1478844239,"solveCount":"0"}';

SynCommons.RecordLoadJSON(R, s, TypeInfo(TR) );

#8 mORMot 1 » Load from invalid JSON » 2016-10-24 04:07:57

g00gle
Replies: 1

for example I have my data container like this:

  TGroup = record
    V1: string;
    V2: Integer;
  end;
  TGroups = array of TGroup;
  ..............
  var AR: TDynArray;    Group: TGroups;   Json1, Json2: RawUTF8;
  ..............

  and invalid JSON string like this:

  Json1 :=   PUTF8Char('[{"VX":"TTT","V2":3},{"V1":"VVV","V2":5},{"V1":"","V2":0}]');

  so if i try to fill my Group from Json1 like :

  AR.Init(TypeInfo(TGroups) ,Group);
  AR.LoadFromJSON( PUTF8Char(Json1) );

  then nothing is loaded.

  is there any solution to skip invalid item and load from Json in that part where it has valid data (index 1 and 2) ?

Board footer

Powered by FluxBB