Jump to content
Registration disabled at the moment Read more... ×
RDP1974

json string to FD MemTable

Recommended Posts

hello,

 

can someone has a function that pass a JSON array string -> to a -> Firedac TFDMemTable

 

thanks

 

Share this post


Link to post

var
  LField: TField;
begin
  mtEmpty.LoadFromJSON(memoEmpty.Lines.Text);
  for LField in mtEmpty.Fields do
    mmDataType.Lines.Add(Format('Field: %s - %s', [LField.FieldName, GetEnumName(System.TypeInfo(TFieldType), Ord(LField.DataType))]));
 

this is enough, calling LoadFromJSON directly from firedac table

however

 

(webbroker post)

if I load from Request.ContentFields.Text (posting raw json) I get a general error

if I load from Request.ContentFields.Values['mandatory'] it's working

then some minor trouble re-serializing with JsonSuperObject with characters unicode utf8, etc. I'll take a look

 

Share this post


Link to post

ah Webbroker calling Request.Content (example for POST body) is applying encoding/decoding text

but there is a method to access the raw content as TBytes

I found webbroker classes to be excellent

Share this post


Link to post

You want to copy from the Request to a table? Wouldn't load the Request, call a web service, then copy from the Response to the table?

 

I'm not completely sure what you're doing but I've been working with REST services in Delphi 10.4 and find that hooking up a TRESTResponseDataSetAdapter to both the TRESTResponse and a TFDMemTable does all the work of parsing a JSON response string into a memory table for me--no code!

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×