FastReport icon indicating copy to clipboard operation
FastReport copied to clipboard

Fixes a problem with Empty arrays using JSON datasources

Open figloalds opened this issue 11 months ago • 0 comments

Previously if you had a an array of complex objects including arrays inside them, you would get a NullReferenceException if the incoming data could have any of those internal arrays be empty. With the added check, the program will correctly understand the lack of value in that property path

Eg:

[
  {
    "items": [{ 
        "productId": 12, "description": "A product of all time" 
    }],
    "payments": [{ "paymentMethodId": 8, "paymentMethodName": "Credit Card", "value": 123.0 }],
    "status": "completed"
  },
  {
    "items": [{ 
        "productId": 6, "description": "Something Really Fancy"
    }]
    "payments": [],
    "status": "cancelled"
  }
]

in the model above, if you were to use a path like sales.payments.value as a totalizer, the data above would cause a NullReferenceException due to payments being an empty array, instead of the expected behavior, with the correction we get the expected result of 123

figloalds avatar Feb 20 '25 19:02 figloalds