Archive JSON: Fixed null pointer dereferences

When the time period for the state change list and availability queries in
the archive JSON is sufficiently small, there may be no entries in the list.
Previously this could have caused pointers that were never initialized to
be deferenced. This commit adds checks to verify that those pointers are not
null before using them.