Testing for empty dictionaries

So, the following code

if (data.isEmpty()) {

gives:
Error: Array Out Of Bounds Error

when it's "Lang.Dictionary {size: 0}"

Similarly,

if (data.size() == 0) {

Also gave the same error.

So what can I do to test its size so it doesn't crash?!?