Jump to content
Magno

Getting Unknown storage format [BIN] even with the JSON storage

Recommended Posts

I am starting a very new Datasnap REST server. Made a simple function to return a query  but I am getting the error of the the title's post (Unknown storage format [BIN] ...) I dropped the Json storage for reflect, follow a lot of examples, that's simple, but simply does not works here. Any tip?

Share this post


Link to post
49 minutes ago, Lars Fosdal said:

Looks hard at the provided examples of the problem, but draws a blank...

I thought someone could understand, I am trying this: http://docwiki.embarcadero.com/RADStudio/Rio/en/Tutorial:_Using_a_REST_DataSnap_Server_with_an_Application_and_FireDAC

 

Have any table and need to create a function to return its result. The program is complaining that I should provide a valid standard storage (I am using http://docwiki.embarcadero.com/Libraries/Rio/en/FireDAC.Stan.StorageJSON.TFDStanStorageJSONLink

 

About the examples, there are a lot over there, as I told: not working. So whats the catch? Any tip?

Share this post


Link to post

I tried a simple new project, drop the required, following this example: http://docwiki.embarcadero.com/RADStudio/Rio/en/Tutorial:_Using_a_REST_DataSnap_Server_with_an_Application_and_FireDAC (same above)

 

So I get an error (as the title of this thread suggests) when running the following method: 

function TServerMethods1.GetDepartmentNames: TFDJSONDataSets;
begin
  // Clear active so that query will reexecute.
  FDQueryDepartmentNames.Active := False;
  Result := TFDJSONDataSets.Create;
  // The "TFDJSONDataSetsWriter" class provides static "ListAdd" method.
  // It uses reflection to convert results of the query into "TFDJSONDataSets".
  TFDJSONDataSetsWriter.ListAdd(Result, FDQueryDepartmentNames);
end;

 The unique difference is that the FDQueryDepartmentNames has another name and points to a similar very simple table with a "select * from users".

 

Share this post


Link to post

I have this same problem. Solved?

 

I need to access the REST / Datasnap server with angular 9.0. 
In this BIN format I cannot.

 

{"result": [{"type": "Data.FireDACJSONReflect.TFDJSONDataSets","id": 1,"fields": {"FDataSets": {"type": "System.JSON.TJSONObject","id": 2,"fields": {"FMembers": [{"type": "System.JSON.TJSONPair","id": 3,"fields": {"FJsonString": {"type": "System.JSON.TJSONString","id": 4,"fields": {"FValue": "FDQuery1","FIsNull": false,"FOwned": true}},"FJsonValue": {"type": "System.JSON.TJSONString","id": 5,"fields": {"FValue": "eJydVO1y0lAQPSkkIiKNGJVWbP3hC1SfIA3q+IFW0PqzEwtiZtLAQLDiu/iqieduPuZCYaYDTODs\r\n2Y+zd9mL2z0d7GNY/1cBUhgw0r20UoUN4A26+IIFRphhiROYwk4wxW9c4Ir8HD4sJgF3oF414C5e\r\nEqT19F4VVaJ3LGKWKAu+jwaaMPZh2DAewGjBeCi1P+MM56zdw2sM4MIpExNVr0HDY1CX1Ft+mzcY\r\nC3tS/xEeMxlK5YkItQutbULrlQ4kX2RbBF0J9NCn22OCEt/MW6js2MLmelojHC++0nEm8rplyaAy\r\nUaMUPbydrl7oQNLLaQ/ocPl8IzJvMBa5nVXXi2nKdQJXWjrnt7lmW3zvrLpaStN08kW7YGiPaf08\r\nxdzqsWTp812+5U+8rVaSpE+TtJOkzxLCoyQ9Tp8TNRnkI+Izllt4xElNMaQdy+3r83OMgCiWO9ri\r\nyXz8QEj+Y87XNa6GT8Tq5jqUnfBuz3BJq2DtFVY1WmQr/ILNRvjJiMzvEUW5tk+1iGjOHnuCA1Zc\r\n8PHom/K5JBOzR0fyQvFFZZeNFbbJM8bUVBVf8Q/Fpro6s89ulqyW9T+irTr5pZ3vlHhO1OLwVb4+\r\nLzvnvjNDTXNE1Yz5QLzEIa0Z+xlL/9m5i8ms+rJeC19bunVlFgH7iiUyYmyNVoC/0o/LjJB518xb\r\nCHZYcxOr/wZFvs1/4wB/iIac2YjVOxvnX8zT5uIFjLsumSa3ZaLZbdmeUGYTSKXC01nbsvd5P2oP\r\nQ9bxZOKR7OQc/wGJQuTy","FIsNull": false,"FOwned": true}},"FOwned": true}}],"FOwned": true}}}}]}

 

Edited by Vinicius Silva

Share this post


Link to post

try remove "{result:[ ... ]}", then you'll have a another vetorS from your matrix! xx[0] = [.. real values used ..]

Quote

{"type": "Data.FireDACJSONReflect.TFDJSONDataSets","id": 1,"fields": {"FDataSets": {"type": "System.JSON.TJSONObject","id": 2,"fields": {"FMembers": [{"type": "System.JSON.TJSONPair","id": 3,"fields": {"FJsonString": {"type": "System.JSON.TJSONString","id": 4,"fields": {"FValue": "FDQuery1","FIsNull": false,"FOwned": true}},"FJsonValue": {"type": "System.JSON.TJSONString","id": 5,"fields": {"FValue": "eJydVO1y0lAQPSkkIiKNGJVWbP3hC1SfIA3q+IFW0PqzEwtiZtLAQLDiu/iqieduPuZCYaYDTODs\r\n2Y+zd9mL2z0d7GNY/1cBUhgw0r20UoUN4A26+IIFRphhiROYwk4wxW9c4Ir8HD4sJgF3oF414C5e\r\nEqT19F4VVaJ3LGKWKAu+jwaaMPZh2DAewGjBeCi1P+MM56zdw2sM4MIpExNVr0HDY1CX1Ft+mzcY\r\nC3tS/xEeMxlK5YkItQutbULrlQ4kX2RbBF0J9NCn22OCEt/MW6js2MLmelojHC++0nEm8rplyaAy\r\nUaMUPbydrl7oQNLLaQ/ocPl8IzJvMBa5nVXXi2nKdQJXWjrnt7lmW3zvrLpaStN08kW7YGiPaf08\r\nxdzqsWTp812+5U+8rVaSpE+TtJOkzxLCoyQ9Tp8TNRnkI+Izllt4xElNMaQdy+3r83OMgCiWO9ri\r\nyXz8QEj+Y87XNa6GT8Tq5jqUnfBuz3BJq2DtFVY1WmQr/ILNRvjJiMzvEUW5tk+1iGjOHnuCA1Zc\r\n8PHom/K5JBOzR0fyQvFFZZeNFbbJM8bUVBVf8Q/Fpro6s89ulqyW9T+irTr5pZ3vlHhO1OLwVb4+\r\nLzvnvjNDTXNE1Yz5QLzEIa0Z+xlL/9m5i8ms+rJeC19bunVlFgH7iiUyYmyNVoC/0o/LjJB518xb\r\nCHZYcxOr/wZFvs1/4wB/iIac2YjVOxvnX8zT5uIFjLsumSa3ZaLZbdmeUGYTSKXC01nbsvd5P2oP\r\nQ9bxZOKR7OQc/wGJQuTy","FIsNull": false,"FOwned": true}},"FOwned": true}}],"FOwned": true}}}}

 

here a brief explanation about "result:[" in JSON response: FormatResult Event for REST Responses

https://mathewdelong.wordpress.com/2011/09/15/delphilive-2011-recap/

 

NOTE: you can defined "Handled = true" to get some similar!

 

Edited by programmerdelphi2k

Share this post


Link to post
3 hours ago, programmerdelphi2k said:

try remove "{result:[ ... ]}", then you'll have a another vetorS from your matrix! xx[0] = [.. real values used ..]

 

here a brief explanation about "result:[" in JSON response: FormatResult Event for REST Responses

https://mathewdelong.wordpress.com/2011/09/15/delphilive-2011-recap/

 

NOTE: you can defined "Handled = true" to get some similar!

 

 

This is my function, where?

 

function TServerMethods1.GetAnaforn: TFDJSONDataSets;
begin
          // Clear active so that query will reexecute.
       FDQueryAnaforn.Active := False;
      Result := TFDJSONDataSets.Create;
  // The "TFDJSONDataSetsWriter" class provides static "ListAdd" method.
  // It uses reflection to convert results of the query into "TFDJSONDataSets".
      TFDJSONDataSetsWriter.ListAdd(Result, FDQueryAnaforn);

end;

Share this post


Link to post

I dont know your code, then, the basic idea will be some like this:

uses
  FireDAC.Comp.Client,
  Data.FireDACJSONReflect; // FD reflection

var // just for show "how will be..." - NOT REAL CASE!!!  just for show the main idea here!
  fdsjListOfDatasetsFromServer: TFDJSONDataSets;
  fdDS_Server_With_Data       : TFDMemTable; // any FD-dataset class in your app!!!
  fdDS_Client_To_Receive_Data : TFDMemTable;

var
  LjsDS: TFDJSONDataSets;
  //
//............//
  /// ========= on server software
  LjsDS := TFDJSONDataSets.Create; // on server...
  //
  // serialization on server
  TFDJSONDataSetsWriter.ListAdd(LjsDS, 'a name for your dataset, just for control', fdDS_Server_With_Data);
  //
  // ----------------------------//
  //
  /// ========= on client software
  // deserialization on client
  fdDS_Client_To_Receive_Data.AppendData(TFDJSONDataSetsReader.GetListValue(fdsjListOfDatasetsFromServer, 0 { what dataset on list? } ));

 

Share this post


Link to post

For now i don't have a client, i want just expose the data in json format in web browser, because i take the json data with php application.

But in my get address in the browser i have the data like this:

eJydVO1y0lAQPSkkIiKNGJVWbP3hC1SfIA3q+IFW0PqzEwtiZtLAQLDiu/iqieduPuZCYaYDTODs\r\n2Y+zd9mL2z0d7GNY/1cBUhgw0r20UoUN4A26+IIFRphhiROYwk4wxW9c4Ir8HD4sJgF3oF414C5e\r\nEqT19F4VVaJ3LGKWKAu+jwaaMPZh2DAewGjBeCi1P+MM56zdw2sM4MIpExNVr0HDY1CX1Ft+mzcY\r\nC3tS/xEeMxlK5YkItQutbULrlQ4kX2RbBF0J9NCn22OCEt/MW6js2MLmelojHC++0nEm8rplyaAy\r\nUaMUPbydrl7oQNLLaQ/ocPl8IzJvMBa5nVXXi2nKdQJXWjrnt7lmW3zvrLpaStN08kW7YGiPaf08\r\nxdzqsWTp812+5U+8rVaSpE+TtJOkzxLCoyQ9Tp8TNRnkI+Izllt4xElNMaQdy+3r83OMgCiWO9ri\r\nyXz8QEj+Y87XNa6GT8Tq5jqUnfBuz3BJq2DtFVY1WmQr/ILNRvjJiMzvEUW5tk+1iGjOHnuCA1Zc\r\n8PHom/K5JBOzR0fyQvFFZZeNFbbJM8bUVBVf8Q/Fpro6s89ulqyW9T+irTr5pZ3vlHhO1OLwVb4+\r\nLzvnvjNDTXNE1Yz5QLzEIa0Z+xlL/9m5i8ms+rJeC19bunVlFgH7iiUyYmyNVoC/0o/LjJB518xb\r\nCHZYcx

Share this post


Link to post

as explained in Mathew's post, you can manipulate the response to whatever you want.
You don't necessarily need to return a JSON format, in fact you can manipulate the response to whatever format you want. In the end, everything will be a text (string). You are the one who determines the result, not the DataSnap! For convenience and usage, JSON is the default returned format!  But you are the one who determines what will be returned!
See the event used for this in your project!

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×