#1 mORMot 1 » Custom serializer reader to return objectlist » 2017-04-03 08:17:08

Del
Replies: 7

I have a json string containing a collection of objects that I want to read into an object list. Are then any examples that showcase this behaviour? Essentially just like jsontoobject using a objectlist but with the ability to customize field mappings.

#2 Re: mORMot 1 » Custom Reader for JSON Serialization with array value » 2017-04-02 10:25:36

Del

Thanks. I want to apply a custom reader to a json string returning an object list, any samples for this scenario?

#3 Re: mORMot 1 » Custom Reader for JSON Serialization with array value » 2017-03-31 22:27:42

Del

@mohsenti do you have some sample code using a custom reader for json serialization to share? I will be need that in a while and initial analysis of custom reader did not seem clear to me quickly so an exmple might pave way for me, many thanks:)

#4 Re: mORMot 1 » Mormot winhttp client(s) with node.js express backend error 12002 » 2017-03-29 22:55:03

Del

Just in case this helps others... Issue turned out to be some blocking behaviour I implemented when committing to the database (not a node issue at all). I took the opportunity to implement clustering though and am thoroughly impressed with throughput and resilience gained from clustering.

#5 Re: mORMot 1 » Mormot winhttp client(s) with node.js express backend error 12002 » 2017-03-29 10:50:09

Del

Very interesting mpv, thanks for that, will definitely give it a go! I would have thought it shouldn't struggle though since I am doing quite basic operations, each POST insert a very basic record into a db.

#6 Re: mORMot 1 » Mormot winhttp client(s) with node.js express backend error 12002 » 2017-03-29 10:47:13

Del

Sorry Arnaud I am not following your train of thought... what are you suggesting? Nothing obviously wrong with the above then and you would expect the same as I would from the POC?

#7 mORMot 1 » Mormot winhttp client(s) with node.js express backend error 12002 » 2017-03-29 04:20:45

Del
Replies: 6

I am doing a POC using mormot winhttp, json serializing to a local node.js express service.  To test resilience, performance I execute two instances of test app (using winhttp performing in order of 1000 sequential POST's from each client concurrently) to EXPRESS service (all running on the same computer) and am finding that 1 client works fine but when i initiate POST from two clients simultaneously one client inevitably throws a Winhttp 12002 (operation timed out) error. Anyone have any experience with this, I am either 'abusing / misconfiguring' winhttp or have neglected to configure EXPRESS properly as it surely should not crumble under these conditions.

Initializing and POST request using winhttp is as follows

fclient := TWinHTTP.Create('localhost', '3002', False, EmptyStr,EmptyStr, 10000,10000,10000);

res := fclient.Request('test', 'POST', 0, Hdr.Header, EmptyStr, EmptyStr, outHDr, OutData);

#8 Re: mORMot 1 » Delphi package using mormot compiler error » 2017-03-28 20:48:25

Del

I have figured it out. In Project Options -> Delphi Compiler -> Output - C/C++ menu the setting C/C++ Output File generation DEFAULTS to Generate all C++ Builder files (including package libs) even for a Delphi package....

Change this setting to Generate DCUs only, recompile...  resulting in 0 errors. Hope this helps someone else.

#9 Re: mORMot 1 » Delphi package using mormot compiler error » 2017-03-28 11:34:00

Del

I wanted to use packages to pursue a plugin based approach with specific implementations  relying on mormot.

#10 Re: mORMot 1 » Delphi package using mormot compiler error » 2017-03-28 10:22:50

Del

If i include SynBidirSock in an app it compiles just fine.

My uses clause from a mormot perspective in package (that fails to compile) includes the following: SynCrtSock, SynCommons,   mORMot,  mORMotHttpClient

#11 Re: mORMot 1 » Delphi package using mormot compiler error » 2017-03-28 07:48:07

Del

Changed Conditional defines at project level to be as follows: USEPACKAGES;DEBUG and included {.$define USEPACKAGES} in .dpk file.

Compiling for 32 bit  WIndows target.

Using Delphi XE2 Update 4 Hotfix 1, also have IDE Fix pack XE2 5.95 installed.

Same error still occurring.

#12 Re: mORMot 1 » TWinHTTP exception handling » 2017-03-28 07:23:29

Del

Thanks Arnaud, did not know about TURI. Will have a look. There are loads of functionality around the periphery of mormot that is very useful but with very little mention / examples. I find myself having to ask questions here due to this. I must give thanks for an awesome framework though, has already saved me loads of time:)

#13 mORMot 1 » Delphi package using mormot compiler error » 2017-03-28 03:30:29

Del
Replies: 10

I built some classes (based on TWinHTTP + other) and used it in a Delphi app but would like to separate these into a Delphi package. When I do this however the exact same code (that compiles fine as an app) throws numerous errors related to mormot.

Errors as follows,

[DCC Error] SynBidirSock.pas(755): E1025 Unsupported language feature: 'Object'
[DCC Error] SynBidirSock.pas(803): E1025 Unsupported language feature: 'Object'
[DCC Error] SynBidirSock.pas(821): E1025 Unsupported language feature: 'Object'
[DCC Error] SynBidirSock.pas(847): E1025 Unsupported language feature: 'Object'
[DCC Error] SynBidirSock.pas(926): E1025 Unsupported language feature: 'Object'
[DCC Error] SynBidirSock.pas(1054): E1025 Unsupported language feature: 'Object'
[DCC Error] SynSSPI.pas(100): E1025 Unsupported language feature: 'Object'
[DCC Error] SynSSPI.pas(106): E1025 Unsupported language feature: 'Object'
[DCC Error] SynSSPI.pas(109): E1025 Unsupported language feature: 'Object'
[DCC Error] SynSSPI.pas(115): E1025 Unsupported language feature: 'Object'
[DCC Error] mORMot.pas(2388): E1025 Unsupported language feature: 'Object'
[DCC Error] mORMot.pas(2404): E1025 Unsupported language feature: 'Object'
[DCC Error] mORMot.pas(3690): E1025 Unsupported language feature: 'Object'
[DCC Error] mORMot.pas(4771): E1025 Unsupported language feature: 'Object'
[DCC Error] mORMot.pas(4854): E1025 Unsupported language feature: 'Object'
[DCC Error] mORMot.pas(8915): E1025 Unsupported language feature: 'Object'
[DCC Error] mORMot.pas(8911): E1025 Unsupported language feature: 'Object'
[DCC Error] mORMot.pas(8915): E1025 Unsupported language feature: 'Object'
[DCC Error] mORMot.pas(10726): E1025 Unsupported language feature: 'Object'
[DCC Error] mORMot.pas(16072): E1025 Unsupported language feature: 'Object'
[DCC Error] mORMot.pas(16081): E1025 Unsupported language feature: 'Object'

Am I missing some directives or something similar?

#14 Re: mORMot 1 » TWinHTTP exception handling » 2017-03-28 00:43:46

Del

Thanks igors233, I should have just passed the relative route to the request instead of full URI. Example much appreciated.

#15 Re: mORMot 1 » TWinHTTP exception handling » 2017-03-27 08:16:50

Del

I would appreciate an example of Request method with GET and POST method, i've tried

res : Integer;
outHDr, OutData : SockString;

res := fclient.Request('http://localhost:3002/testroute', 'GET', 0, Hdr.Header, EmptyStr, EmptyStr, outHDr, OutData);

where Hdr.Header provides Header string collection (works for GET method)
same url used for GET method and works but for Request method returns a 404.

I could not see any example or documentation outlining the Request method in detail.

Thanks

#16 mORMot 1 » TWinHTTP exception handling » 2017-03-27 04:10:36

Del
Replies: 6

I am using TWinHTTP, specifically Get and Put methods which seem to suppress any exceptions (404 etc) just returning an empty payload. I would like to handle / be aware of error conditions such as  these in my application however. What would be the correct way of facilitating this?

Thanks

#17 mORMot 1 » TObjectList to dataset approach » 2017-03-26 01:21:14

Del
Replies: 0

I have JSON which I converted to a TObjectList containing a specific class using mormot. I would now like to bind this TObjectList to a GUI and alter some values, what would be the best way to achieve this? I was thinking of going to a dataset (read / write) to provide binding functionality. Is there a better / alternative way? What's the best way to go from TObjectList to TObjectList<T>, as that might also help with other memory related dataset components.

#18 Re: mORMot 1 » Consume non-Mormot REST service JSON to collection of objects » 2017-03-25 11:00:33

Del

Sorted this, had a couple of issues besides for what was mentioned (JSON issues) ... main one being using TObjectlist<> which is not supported. For custom mapping from JSON to object
TJSONSerializer.RegisterCustomSerializer specifying a reader function should be used, correct? Are there any samples available outlining use of such a scenario?

Thanks for an AWESOME Framework!:)

#19 Re: mORMot 1 » Consume non-Mormot REST service JSON to collection of objects » 2017-03-24 19:40:59

Del

Thanks will resolve name for categoryid. I want to have my object's property names deviate from the rest response fields
How do I 'map' this? A simple example would be appreciated. Many thanks

#20 mORMot 1 » Consume non-Mormot REST service JSON to collection of objects » 2017-03-24 13:04:23

Del
Replies: 3

I would like to consume the following JSON result from a REST service into a collection of Category objects. What would be the correct way to go about configuring Mormot to do just that?

{
  "Categories": [
    {
      "CategoryId": 0,
      "CategoryName": "Undefined",
	  "LastModified": "2016-01-15 08:00",
	  "Isactive": 1
    },
    {
      "UnitCategoryId": 1,
      "CategoryName": "Acceleration",	  
	  "LastModified": "2016-01-15 08:00",
	  "Isactive": 1
    },
    {
      "UnitCategoryId": 2,
      "CategoryName": "Angle",	  
	  "LastModified": "2016-01-15 08:00",
	  "Isactive": 1
    },
    {
      "UnitCategoryId": 3,
      "CategoryName": "Area",	  
	  "LastModified": "2016-01-15 08:00",
	  "Isactive": 1
    }    
  ]
}

I tried the following, (a bit dirty as I have been trying to sort this)

TUOM = class(TPersistent)
  protected
    fuomcid: string;
    fuomcn: string;
  published
    property CategoryId: string read fuomcid write fuomcid;
    property CategoryName: string read fuomcn write fuomcn;
  end;

function TMUOMCategoryClient_REST1.Get: Boolean;
var
  fuom: TUOM;
  v: Boolean;
  ll: TList;
  l: TObjectList<TUOM>;
  res, uomc: string;
  cnt: integer;
  cp: TJSONCustomParserCustom;
  r: RawUTF8;
begin

 // cp := TJSONCustomParserCustom.Create('UOMCategoryId', 'CategoryId');


  fd := fclient.Get('http://localhost:3002/uomc', chdr);
  r := RawUTF8(fd); //valid json here
  l := TObjectList<TUOM>.Create(True);
  Res := JSONToObject(l, @r[1], v, TUOM, []); //object list contains nothing
  cnt := l.Count;
end;

Any assistance appreciated.

Board footer

Powered by FluxBB