ASP.NET 5强类型配置JSON格式

时间:2015-12-17 17:18:51

标签: asp.net json configuration

我正在尝试为以下对象利用新的ASP.NET 5配置构建器。有谁知道数组类型字段的JSON语法?

public class ProjectConfiguration
{
    public ProjectSubfolder[] ProjectSubfolders { get; set; }
}

public class ProjectSubfolder
{
    public string Name { get; set; }

    public ProjectPermission[] ProjectPermissions { get; set; }
}

public class ProjectPermission
{
    public string Identity { get; set; }

    public FileSystemRights FileSystemRights { get; set; }

    public InheritanceFlags InheritanceFlags { get; set; }

    public PropagationFlags PropagationFlags { get; set; }

    public AccessControlType AccessControlType { get; set; }
}

我使用的json无法填充ProjectConfiguration.ProjectSubfolders数组,如下所示:

{
    "ProjectConfiguration": {
        "ProjectSubfolders": [
            {
                "Name": "MyName",
                "ProjectPermissions": [
                    {
                        "Identity": "Domain\\ShortId",
                        "FileSystemRights": "FileSystemRights.CreateDirectories",
                        "InheritanceFlags": "InheritanceFlags.None",
                        "PropagationFlags": "PropagationFlags.NoPropagateInherit",
                        "AccessControlType": "AccessControlType.Allow"
                    }
                ]
            }
        ]
    }
}

1 个答案:

答案 0 :(得分:0)

史诗自失败,从原始的基于XML序列化程序的实现转换时,复制/粘贴工作将System.Security.AccessControl类型名称留在值的前面。

"FileSystemRights": "FileSystemRights.CreateDirectories"

应该是

"FileSystemRights": "CreateDirectories"