Why do you return null instead of an empty array if data is a collection of items?

I get null in data field when query products of an active deal which has products_count = 0.

I would expect empty array ([]), not null.

Hi @voroninp,

It’s a pretty valid point really. The honest answer is that this is simply how our code was originally written (to return null) and we have stuck with it, but one thing to note is that an empty array means some memory is allocated to it while null would mean it is empty.

It is certainly food for thought though and perhaps something we can look into again and maybe change.

Thanks for the reply.

I’ll leave this link telling how to make Json.NET deserializer automatically replace null with empty collection when needed.