CLN: Fix return type for initObjToJSON()

Make it so that it always returns the same thing as numpy, so that it
matches the right signature whether in or not in the error condition.

Closes #5326.