You are not logged in.
Pages: 1
Hello,
I am provided following json which seems to be a valid json according to an online json validator.
http://pasted.co/5449b77b
I have setup my records as follows and I am not able to de-serialize it as function returns false to me. Could not find and solve what problem is here. I appreciate any help.
 THasta = packed record
   hastaTC: string;
   adSoyad: string;
 end;
 TGebelikBildirim = packed record
   sysTakipNo: string;
   hekimAdSoyad: string;
   kurumAdi: string;
   kangrubu: Smallint;
   islemzamani: string;
   sonadettarihi: string;
   gonderimZamani: string;
 end;
 TGebelikBildirimleri = TArray<TGebelikBildirim>;
 TSonuc = packed record
   hasta: THasta;
   gebelikBildirim: TGebelikBildirimleri;
 end;
 TSonuclar = TArray<TSonuc>;
 TResult = packed record
   durum: Smallint;
   sonuc: TSonuclar;
   mesaj: string;
 end;Below is the code piece I am using to de-serialize:
procedure TForm1.Button1Click(Sender: TObject);
var
  JsonRecord: TResult;
  JsonString: string;
  i, i2: Integer;
begin
  ClientDataSet1.EmptyDataSet();
  JsonString := memJson.Text;
  if not RecordLoadJSON(JsonRecord, StringToUTF8(JsonString), TypeInfo(TResult)) then
  begin
    ShowMessage('Json de-serialize failed!');
  end
  else
  begin
    // Some database saving code here
  end;
end;Thanks & regards,
Ertan
Offline
I found problem and its solution.
THasta record was presented me in an earlier sample json with 2 variables in it. Current real-life json includes 3 variables in it. Once I added 3rd variable in THasta record definition everything started to work again.
Thanks.
Offline
The problem is that j2oIgnoreUnknownProperty option do not work in the record de-serialize.
Offline
Pages: 1