You are not logged in.
Pages: 1
Hi Ab,
Do you have in plans add support for brotli compression algorithm ?
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.
2 turrican
Are you seriously ?
I'm strongly recommend to you read my second post: http://synopse.info/forum/viewtopic.php … 303#p22303
2 turrican
read careful This is not JSON from my side. :\ http://synopse.info/forum/viewtopic.php … 303#p22303
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;
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.
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) );
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) ?
Pages: 1