10

I want a JSON schema that enforces an empty JSON object, e.g. {}

Is this a good idea and possible?

I tried the following but it allows me to enter anything in the JSON body:

{
   "description": "voice mail record",
   "type": "object",
   "additionalProperties": false,
   "properties": {
    }
 }
dpoggi
  • 82
  • 5
AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152
  • how about enforcing the opposite? I mean [non-emptiness of object](http://stackoverflow.com/questions/35651589/enforce-object-non-emptyness-using-json-schema)? – Mahesha999 Feb 26 '16 at 12:47
  • 2
    @Mahesha999 swap `additionalProperties: false` for `minProperties: 1`. – Luke Feb 21 '17 at 20:46

1 Answers1

10

The answer yes this should enforce an empty schema - the validator I was using had a bug

http://groups.google.co.uk/group/json-schema/browse_thread/thread/d0017b3985c8542b/106ce4afc1763eeb?hl=en&q=empty+schema+ollie&safe=on

AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152