BasisHub / components

BASIS Components
Other
7 stars 9 forks source link

NPE in fromJson for specific sample #189

Closed StephanWald closed 3 years ago

StephanWald commented 4 years ago
REM /**
REM  * test.bbj
REM  *
REM  */

use com.basiscomponents.db.DataRow
use com.basiscomponents.db.ResultSet

class public test

    REM /**
    REM  * constructor
    REM  */
    method public test()
    methodend

    method public void test()

        declare ResultSet rs1!
        declare DataRow dr1!
        declare BBjString strJson!
        strJson!="{""isActive"":true,""vehicle"":{""licensePlate"":""01AUCO"",""make"":""PEUGEOT"",""model"":""307"",""objectType"":{""code"":""PV"",""description"":""PersonenVervoer < 9 pers.""},""fuelTypeCode"":{""code"":""D"",""description"":""Diesel""},""type"":""2.0 HDI 80KW SW"",""firstRegisteredDate"":""2003-02-17T00:00:00"",""maintenance"":{""lastMaintenanceCode"":""0"",""lastMaintenanceDate"":""2006-01-01T00:00:00""},""currentTireSeasonCode"":{""code"":""W"",""description"":""Winter""},""currentTireCategoryCode"":{""code"":""S"",""description"":""Standaard""},""tirePositions"":[{""positionCode1"":""1"",""positionCode2"":""L""},{""positionCode1"":""1"",""positionCode2"":""R""},{""positionCode1"":""2"",""positionCode2"":""L""},{""positionCode1"":""2"",""positionCode2"":""R""}],""mountedTires"":[],""storedTires"":[]},""lessor"":{""number"":934736,""name"":""Test LM Aucon""},""endDate"":""2014-12-31T00:00:00"",""maximumMileage"":100000,""information"":"" "",""reliefVehicleInformation"":"" "",""permissions"":{""maintenance"":true,""reliefVehicle"":true,""tires"":true,""tireSwap"":true,""tireReplace"":true,""tireWithoutMounting"":false,""winterTires"":""IncludedInLeaseContract"",""usedTires"":true,""allSeason"":""Allowed"",""runOnFlat"":""Allowed"",""nitrogen"":true,""deliveryCosts"":false,""pickupCosts"":false,""fillupCosts"":false,""profileDepthExemption"":true},""allowedTireCosts"":{""storageCosts"":true,""transportCosts"":true,""surchargeNitrogen"":true,""surchargeRunOnFlat"":true,""surchargeLargeRim"":true,""surchargeMobileService"":true,""surchargeTruckTire"":false,""handlingCostLessorStock"":true,""handlingCostThirdPartyTire"":true,""disposalFee"":true,""deliveryFeeToDealer"":true},""maxDeployableRentalClass"":""G"",""winterTireSetAlreadyPurchased"":false}"
        dr1!=DataRow.fromJson(strJson!)
        rs1!= cast(ResultSet,dr1!.getFieldValue("tirePositions"))

    methodend                                 

classend

rem my test
declare test test!
test!=new test()
test!.test()
escape
StephanWald commented 3 years ago

This is invalid. tirePositions is in the hierarchy under vehicle and hence cannot be accessed directly in the root object