Require JSON to have an element When working with the json datatype, is there a way to ensure the input JSON must have an element?

I don't mean primary, I want the JSON that gets inserted to at least have the id, name element. It can have more but at the minimum those two must be there. Can this be done?
You can do that with a column check:

ALTER TABLE table ADD
  CHECK ((column-&gt;'id') is not null and (column-&gt;'name') is not null);