Getting this response when invoking vision.documentTextDetection()
[{
faceAnnotations: [],
landmarkAnnotations: [],
logoAnnotations: [],
labelAnnotations: [],
textAnnotations: [],
localizedObjectAnnotations: [],
safeSearchAnnotation: null,
imagePropertiesAnnotation: null,
error: null,
cropHintsAnnotation: null,
fullTextAnnotation: null,
webDetection: null,
context: null
}]
What's the point in some properties as empty arrays and some as null?
I'm trying to make conditional rendering and got stuck on truthy values when IRL they aren't.
I can't speak for the creators of the API, but it makes sense in terms of you writing less code to get more work done.
If the array fields in question are always arrays and nothing else, then you simply make the assumption in your code that they are arrays. This means that if you want to know if something was returned in that array safely, then all you have to do is check the length of the array, or just iterate it.
On the other hand, if the array fields in question are sometimes arrays, maybe null, then you have to write code to first check if the array field is null, then write code to check the array.
Which would you rather do? 1) Assume the field is an array and deal with it. Or 2) Check to see if it's actually an array, then deal with it as such? Seems to me that it's more convenient to just assume array, and write less code.