Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
svc rest API:JSON的序列化问题_Json_Serialization_Restapi - Fatal编程技术网

svc rest API:JSON的序列化问题

svc rest API:JSON的序列化问题,json,serialization,restapi,Json,Serialization,Restapi,我有一个带有JSON的svc REST API来获取数据: <OperationContract()> <WebInvoke(Method:="GET", ResponseFormat:=WebMessageFormat.Json, RequestFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Bare, UriTemplate:="employer/ID/{employe

我有一个带有JSON的svc REST API来获取数据:

<OperationContract()>
<WebInvoke(Method:="GET", ResponseFormat:=WebMessageFormat.Json, RequestFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Bare, UriTemplate:="employer/ID/{employerID}")>
Function GetEmployer(employerID As String) As clsOpdrachtgever

函数GetEmployer(employerID作为字符串)作为clsOpdrachtgever
我对JSON的序列化有问题

在我的类中,我使用Newtonsoft.json分配JSONproperty名称:

Imports System.ComponentModel 
Imports System.ComponentModel.DataAnnotations
Imports Newtonsoft.Json

Public Class clsEmployer

    <JsonProperty("Name", Required:=Required.Always)> <StringLength(250)> Public Property T200_Naam As String
    <JsonProperty("LegalForm", Required:=Required.Always)> <StringLength(2)> Public Property T200_Rechtsvorm As EnumLegalForm
    <JsonProperty("SocialSecurityNumber", Required:=Required.DisallowNull)> Public Property T200_RSZNr As Decimal?
    <JsonProperty("prefixVATnumber", Required:=Required.Always)> <StringLength(2, MinimumLength:=2)> <DefaultValue("BE")> Public Property T200_PrefixBTWNr As String
    <JsonProperty("VATnumber", Required:=Required.Always)> <StringLength(9, MinimumLength:=9)> <RegularExpression("^[0-9]*$")> Public Property T200_BTWNr As String
    <JsonProperty("VATIndex", Required:=Required.DisallowNull)> <DefaultValue("VAT_liable")> Public Property T200_BTWIndex As EnumBTWIndex
    <JsonProperty("DefaultOffice", Required:=Required.DisallowNull)> Public Property T200_KantoorNr As Integer?
    <JsonProperty("InvoiceDueDate", Required:=Required.DisallowNull)> Public Property T200_FactuurVervaldag As EnumInvoiceDueDate?
    <JsonProperty("InvoiceSplit", Required:=Required.DisallowNull)> <DefaultValue("Standard_per_contract")> Public Property T200_FactuurOpsplitsing As EnumInvoiceSplit?
    <JsonProperty("Language", Required:=Required.DisallowNull)> <DefaultValue("N")> Public Property T200_Taal As EnumLanguage
    <JsonProperty("ExternID", Required:=Required.DisallowNull)> <StringLength(50)> Public Property T200_ExternID As String
    <JsonProperty("Note", Required:=Required.DisallowNull)> <StringLength(500)> Public Property T200_Opmerking As String

End Class
导入System.ComponentModel
导入System.ComponentModel.DataAnnotations
导入Newtonsoft.Json
公共类clsEmployer
公共财产T200_Naam作为字符串
公共财产T200_Rechtsvorm作为EnumLegalForm
公共财产T200_RSZNr为十进制?
公共属性T200_前缀xbtwnr作为字符串
公共属性T200_BTWNr作为字符串
公共财产T200_BTWIndex作为EnumBTWIndex
公共属性T200_KantoorNr作为整数?
公共财产T200_factuUserValdag作为EnumInvoiceDueDate?
公共财产T200_factu作为EnumInvoiceSplit进行拆分?
公共财产T200_Taal作为一种语言
公共属性T200_ExternID作为字符串
公共属性T200_Opmerking作为字符串
末级
调用API时,响应不包含JSONproperty名称: { “T200_BTWIndex”:0, “T200_BTWNr”:“44444 2063”, “T200_外部”:“, “T200_-facturopspliting”:2, “T200_factuUserValdag”:0, “T200_KantoorNr”:2201, “T200_Naam”:“雇员”, “T200_Opmerking”:“, “T200_前缀XBTWNR”:“BE”, “T200_RSZNr”:0, “T200_Rechtsvorm”:1, “T200_Taal”:0, “t200_nropdrachtgever”:15 }

如何更改响应包含JSON属性名称的API

据我所知,问题在于JSON属性名是在Newtonsoft中定义的,但API没有使用Newtonsoft来序列化数据

有人能帮我修一下吗