Serialize resource

Summary: Fixes #4162

Resources should be serialized as `0` int, or boolean `0` if not a valid resource.

Reviewed By: @JoelMarcey

Differential Revision: D1665854

Signature: t1:1665854:1415336794:f955fc3b238961c2e4096d176525fec593feb335