简体   繁体   English

需要知道字符串和列表的POST JSON正文格式 <string> ormlite-servicestack

[英]Need to know POST JSON Body Format for string and List<string> ormlite-servicestack

I need the expertise help for JSON Body FORMAT for POST List and string. 我需要POST列表和字符串的JSON主体格式的专业帮助。 I have developed the JSON , C# web services by Service Stack. 我已经通过Service Stack开发了JSON和C#Web服务。 I would like to Post the List of 'Timestamp' along with String 'EmployeeId'. 我想与字符串“ EmployeeId”一起发布“时间戳”列表。 But at receiving end (Web Service) I am getting only string type 'EmployeeId'with 但是在接收端(Web服务),我只能得到字符串类型'EmployeeId'
List Timestamp is NULL. 列表时间戳为NULL。 I have tried the number of ways as below. 我尝试了以下几种方法。

Webservice Name: Web服务名称:

http://192.168.1.109/EmployeeDatabase/json/reply/UpdateSyncStatus_EmployeeId_Timestamp

[Route("/UpdateSyncStatus_EmployeeId_Timestamp", "POST")]
public class UpdateSyncStatus_EmployeeId_Timestamp
{
    public string EmployeeId { get; set; }
    public List<string> Timestamp { get; set; } 
}

I am Posting for test via Firefox HttpRequester utility. 我正在通过Firefox HttpRequester实用工具发布测试。

The BODY / Content in JSON format I have tried as below but nothing is working fine. 我尝试了以下JSON格式的BODY / Content,但没有任何工作正常。 I do not know where I am doing mistake: 我不知道我在哪里做错:

1. 1。

{"EmployeeId" : "gopsw_15_05_2015_17_17_571"},[{"Timestamp" : "2015-05-18T12:36:04.379"  ,  "Timestamp" : "2015-05-18T12:38:04.379" ,  "Timestamp" : "2016-05-18T12:38:04.379"}]

2. 2。

{"EmployeeId" : "gopsw_15_05_2015_17_17_571"}, Timestamp : ["2015-05-18T12:36:04.379"  , "2015-05-18T12:38:04.379" ]

3. 3。

{"EmployeeId" : "gopsw_15_05_2015_17_17_571"},[{"Timestamp" : "2015-05-18T12:36:04.379"} , {"Timestamp" : "2015-05-18T12:38:04.379"}]

4. 4。

{"EmployeeId" : "gopsw_15_05_2015_17_17_571"},  "Timestamp" : [{"2015-05-18T12:36:04.379"} , {"2015-05-18T12:38:04.379"}] 

5. 5。

{"EmployeeId" : "gopsw_15_05_2015_17_17_571"},  {"Timestamp"} : [{"2015-05-18T12:36:04.379"} , {"2015-05-18T12:38:04.379"}]

6. 6。

{"EmployeeId" : "gopsw_15_05_2015_17_17_571"},  {{"Timestamp"} : [{"2015-05-18T12:36:04.379"} , {"2015-05-18T12:38:04.379"}]}

The JSON Body that matches this Request DTO: 与此请求DTO匹配的JSON主体:

[Route("/UpdateSyncStatus_EmployeeId_Timestamp", "POST")]
public class UpdateSyncStatus_EmployeeId_Timestamp
{
    public string EmployeeId { get; set; }
    public List<string> Timestamp { get; set; } 
}

Should look like: 应该看起来像:

POST /UpdateSyncStatus_EmployeeId_Timestamp

{"EmployeeId":"gopsw_15_05_2015_17_17_571","Timestamp":["2015-05-18T12:36:04.379","2015-05-18T12:38:04.379"]}

eg There's only 1 JSON Object (the entire DTO) and Timestamp is just an array of strings. 例如,只有1个JSON对象(整个DTO),并且Timestamp只是一个字符串数组。

Whenever you're in doubt and want to know what the JSON should look like you can just serialize the object, eg: 每当您有疑问并想知道JSON的外观时,都可以序列化对象,例如:

var json = new UpdateSyncStatus_EmployeeId_Timestamp {
    EmployeeId = "gopsw_15_05_2015_17_17_571",
    Timestamp = new []{"2015-05-18T12:36:04.379","2015-05-18T12:38:04.379"}.ToList()
}.ToJson();

json.Print();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM