Don’t use this approach with JSON (as opposed to JSONB) type fields though, a single extra space in the JSON structure would already lead to a difference, as would other formatting differences.
I don´t think two equal values being converted to json will be different in any way. If row_to_json of both are different, I suppose both record really are different, no ?