#1 2013-04-16 21:20:02

wai-kit
Member
From: Amsterdam, the Netherlands
Registered: 2012-11-27
Posts: 90

JSONToDataset raise EVariantTypeCastError

Hi,

Has anybody come across this error before: EVariantTypeCastError : could not convert variant of type (UnicodeString) into type (Double)? I get this error when calling
JSONToDataset with this JSON string:

'[{"folio_id":11111,"folio_name":"testfolio 1","startDate":"2013-01-01","closedDate":"2013-01-02","description":null,"startCapital":null,"endCapital":null,"RiskValue":null},
{"folio_id":22222,"folio_name":"testfolio 2","startDate":"2013-01-01","closedDate":null,"description":null,"startCapital":null,"endCapital":null,"RiskValue":null}]'

Whereas with this JSON the error is not raised:

'[{"folio_id":11111,"folio_name":"testfolio 1","startDate":"2013-01-01","closedDate":null,"description":null,"startCapital":null,"endCapital":null,"RiskValue":null},
{"folio_id":22222,"folio_name":"testfolio 2","startDate":"2013-01-01","closedDate":null,"description":null,"startCapital":null,"endCapital":null,"RiskValue":null}]'

The only difference between the two JSON strings is "closedDate":"2013-01-02" and "closedDate":null. The error is raised when converting a to a DateTime field.

I am using the latest version of mORMot.

Regards,

Wai


fpcdeluxe, FPC 3.2 / Lazarus 2.0, mORMot on Windows 10 ...

Offline

#2 2013-04-17 06:22:08

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: JSONToDataset raise EVariantTypeCastError

Offline

#3 2013-04-17 07:42:26

wai-kit
Member
From: Amsterdam, the Netherlands
Registered: 2012-11-27
Posts: 90

Re: JSONToDataset raise EVariantTypeCastError

That did the trick.

Kudos for the fast response ...

Last edited by wai-kit (2013-04-17 07:43:29)


fpcdeluxe, FPC 3.2 / Lazarus 2.0, mORMot on Windows 10 ...

Offline

#4 2013-04-17 12:11:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: JSONToDataset raise EVariantTypeCastError

You are welcome!

smile

Offline

Board footer

Powered by FluxBB