jdorn / json-editor

JSON Schema Based Editor
MIT License
5.81k stars 1.08k forks source link

Edit Map #94

Open decatur opened 10 years ago

decatur commented 10 years ago

What do I miss when setting up an editor for a container object, for example

{
      "anyfoo" : {
        "Region" : "USA",
        "Product" : "Base"
      },
      "anybar" : {
        "Region" : "Germany",
        "Product" : "Base"
      }};

with schema

 {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "type": "object",
        "additionalProperties": false,
        "patternProperties": {
            "$any[a-z]*^": {
                "type": "object",
                "properties": {
                    "Region": {
                        "type": "string"
                    },
                    "Product": {
                        "type": "string"
                    }
                }
            }
        }
    };

The json-editor simply displays nothing, not even errors on console.

decatur commented 10 years ago

Client is IE10.

decatur commented 10 years ago

My bad: Do not want to close!

jdorn commented 10 years ago

additionalProperties set to false stops the Add Properties button from showing up. This is a bug, since it should only do that if there are also no patternProperties defined. Removing additionalProperties should fix it.

Pattern properties are really hard to deal with in the editor UI and not user friendly, so I highly recommend not using them unless absolutely necessary.

decatur commented 10 years ago

Yes, it is indeed difficult to deal with the duality between class versus map style of JSON-objects. I'd also recommend to use lists instead of map-style objects. BUT: In our organisation, the business departments own the schema, and they don't (and should not) care about UI-specific concerns.

decatur commented 10 years ago

Ok, removing "additionalProperties":false alltogether did it. Thanks!

decatur commented 10 years ago

This issue should stay open until the bug with additionalProperties":false is resolved. Please mind that the issue is not with a missing button, but with a missing editor. Also the patternProperties I provided above is wrong. It should read "^any[a-z]*$"