簡體   English   中英

Key:Value 的原始 JSON

[英]Raw JSON for Key:Value

我一直在尋找年齡,發現了一些類似的問題,但沒有解決我的問題的答案。

我最近開發了一個帶有單獨的服務器端和客戶端代碼的 Web API 項目。 我想通過apiary做一些測試,主要是為了發布數據。 這要求我擁有已發布 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
}

所以我通過發送以下 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":[""]
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM