I'm trying to go through the transactions in a block and determine how many segwit inputs or outputs there are.

I've noticed in getrawtransaction that segwit inputs seem to have a 'txinwitness' field. Is that a good way to classify them?

For outputs I know I can't just look at the 3* address because not all p2sh are segwit. So what's the best way there?

EDIT:
I just found this page about 3* addresses. https://bitcoin.stackexchange.com/questions/58662/difference-between-a-segwit-address-and-a-p2sh-address

Am I correct in interpreting this to say that you can't determine whether an output is segwit? Only an input?