Skip to content

Configuration as specified in config.json should be able to handle arrays #620

@rkeithhill

Description

@rkeithhill

In switching to JSON, I thought my AppSettings would get a bit cleaner. In my web.config file I store an array of small objects (Text, ControllerName, ActionName) as a string of JSON. When I read in that setting, I throw it at JSON to parse out the bits of the elements of this array of objects. But when I put this into config.json, I get an "Unsupported JSON token 'StartArray' was found" at startup. Why? It is valid JSON. Why arbitrarily restrict the form? What if one of my settings needs to be an array of objects e.g.:

{
  "AppSettings": {
    "NavBarLinks": [
      { "Text": "A", "Controller": "Fe" },
      { "Text": "B", "Controller": "Fi" },
      { "Text": "C", "Controller": "Fo" },
      { "Text": "D", "Controller": "Fum" }
    ]
  }
}

So now I'm back to encoding JSON inside the string value of a JSON field. Only now I have to escape every double quote. Blech.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions