密钥的原始JSON:值

时间:2016-03-16 14:17:54

标签: json asp.net-mvc testing

我一直在寻找年龄并发现了一些类似的问题,但没有解决问题的问题。

我最近开发了一个带有单独服务器端和客户端代码的Web API项目。我想通过养蜂场进行一些测试,主要是为了发布数据。这需要我有一个发布的JSON的“样本”。但是我似乎无法得到一个工作样本(我使用Postman来测试JSON)。

我发送了一个ViewModel:

public class ExampleViewModel
    {
        public ExampleModel exampleModel { get; set; }
        public String[] strings { get; set; }
    }

使用模型:

public class ExampleModel 
    {
        public long ID { get; set; }
        public string User { get; set; }
        public string Title { get; set; }
        public string Type { get; set; }
        public string Description { get; set; }
        public bool Recieved { get; set; }
        public bool CompleteRemotly { get; set; }
        public bool CompleteInField { get; set; }
        public string Email { get; set; }
        public Nullable<DateTime> RecievedDate { get; set; }
        public Nullable<DateTime> ScheduledFor { get; set; }
        public Nullable<DateTime> CompleteOn { get; set; }
        public string Priority { get; set; }
        public string DiagnosticReports { get; set; }
        public string CReference { get; set; }
        public string JReference { get; set; }
    }

POST期望的格式是:

Key: "evm", 
Value: {APIProject.ViewModels.ExampleViewModel}

APIProject.ViewModels.ExampleViewModel:
{
   strings = [""],
   exampleModel = {ExampleModel}
}

我最近的尝试是:

{
    "evm":{
        "ExampleViewModel":{
            "exampleModel":{
                "ID":0,
                "User":"Harrison",
                "Title":"Other",
                "Type":"Other",
                "Description":"ygfvgufuf",
                "Recieved":true,
                "CompleteRemotly":false,
                "CompleteInField":false,
                "Email":null,
                "RecievedDate":"\/Date(1458133155546)\/",
                "ScheduledFor":null,
                "CompleteOn":null,
                "Priority":"Low",
                "DiagnosticReports":null,
                "CPA_Reference":null,
                "Jira_Reference":null,
                "strings":[]
            },
            "strings":[""]
        }
    }
}

返回:

Key: "evm", 
Value: {APIProject.ViewModels.ExampleViewModel}

APIProject.ViewModels.ExampleViewModel:
{
   strings = null,
   exampleModel = null
}

1 个答案:

答案 0 :(得分:0)

所以我通过发送以下JSON来实现这一点,我想我的情况太复杂了。

{
   "requestManagements":{
                "RequestID":0,
                "User":"Harrison",
                "RequestTitle":"Other",
                "RequestType":"Other",
                "RequestDescription":"ygfvgufuf",
                "RequestRecieved":true,
                "RequestCompleteRemotly":false,
                "RequestCompleteInField":false,
                "Email":null,
                "RequestRecievedDate":"\/Date(1458133155546)\/",
                "ScheduledFor":null,
                "CompleteOn":null,
                "Priority":"Low",
                "DiagnosticReports":null,
                "CPA_Reference":null,
                "Jira_Reference":null,
                "RequestManagerImages":[]
            },
    "images":[""]
}