RTC Forums
November 01, 2024, 01:12:16 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: RtcRecord.CheckType not working after upgrade 7.15 -> 8.25  (Read 5120 times)
jeff.lott
RTC Expired
*
Posts: 11


« on: September 14, 2017, 09:08:01 PM »

Code that worked using RTC 7.15 is not working after upgrade to 8.25

POST JSON Body:
{"idOrder" : 402317,"idProduct" : 5138154,"Packages" : [],"GeoLocation" : "PA-Blakeslee","GeoPrinterDrum" : "GP-C831","GeoPrinterBottle" : "EPSON-ET-4550","PrintMode" : ""}

Code in onDataReceived(Sender: TRtcConnection):
Code:
          PayLoad := Srv.Read;
          LogMessage := LogMessage + #13#10#09 + 'PayLoad: ' + PayLoad;
          Log(LogMessage, '');
          if (PayLoad.IsEmpty) then begin
            message := 'Request must containe JSON Body';
            break;
          end;
          Try
            JSONPayload := TRtcRecord.FromJSON(PayLoad);
          Except
            on E : Exception do begin
              message := 'Invalid JSON request data: ' + E.Message;
              break;
            end;
          End;
          // Now have valid JSon from Body of POST

          if (JSONPayload.CheckType('idOrder', rtc_Integer[) = false) then begin // should return true, but returns false
            if (JSONPayload.CheckType('LOT', rtc_Integer) = false) then begin
              message := 'value for idOrder or LOT must be supplied';
              break;
            end;
            LOT := JSONPayload.asInteger['LOT'];
            idOrder := 0;
          end else begin
            idOrder := JSONPayload.asInteger['idOrder'];
            LOT := 0;

 if (JSONPayload.CheckType('idOrder', rtc_Integer) should return true but it is returning false.
if I do JSONPayload.asInteger['idOrder'] in watch list it correctly shows 402317.

this same CheckType code works on another computer running RTC 8.15.

Not sure why?
Thanks for any help.            
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: September 14, 2017, 09:39:04 PM »

I will check tomorrow morning.

In the meantime, can you please tell me which  Delphi version are you using and which target platform is the App being compiled for?

Also, how is the PayLoad variable declared?

Thanks.

Best Regards,
Danijel Tkalcec

Logged
jeff.lott
RTC Expired
*
Posts: 11


« Reply #2 on: September 14, 2017, 09:55:25 PM »

Var
  JSONPayload: TRtcRecord;
  PayLoad: String;
  idOrder: Integer;
  ...

Laptop-OLD: Delphi XE 10 update 1, RTC 7.15.
Target Win-64 bpl package used as dynamically loaded "snap-in" module for console/win-service app.
Code works as expected.

Laptop-NEW: Delphi XE 10.2 update 1, RTC 8.25.
Target Win-64 bpl package used as dynamically loaded "snap-in" module for console/win-service app.
Code not working as expected.

JSONPayload.CheckType('idOrder', rtc_Integer) returns false
but idOrder := JSONPayload.asInteger['idOrder']; will set idOrder correctly to 402317

 

Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: September 15, 2017, 07:01:22 AM »

Thanks for reporting this.

It was the new number format checker for JSON, which wasn't skipping white-space, resulting in all JSON numbers with white-space to be stored as strings. You could still access the number with asInteger because of the automatic type conversion (implemented for most RTC Value types to-and-from a String).

Please, download RTC SDK v8.28 (just released) and let me know if it works as expected, or if you bump into any other problems.

Best Regards,
Danijel Tkalcec
Logged
jeff.lott
RTC Expired
*
Posts: 11


« Reply #4 on: September 15, 2017, 02:00:57 PM »

It is working great now, bug fixed.
Thanks for the quick response.
Best Regards, Jeff
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.025 seconds with 17 queries.