用于WCF服务的.net类生成器
本文关键字:net WCF 服务 用于 | 更新日期: 2023-09-27 18:02:41
我有这样的JIRA json字符串:
[
{
"self": "http://www.example.com/jira/rest/api/2/project/EX",
"id": "10000",
"key": "EX",
"name": "Example",
"avatarUrls": {
"48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10000",
"24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
"16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000",
"32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000"
},
"projectCategory": {
"self": "http://www.example.com/jira/rest/api/2/projectCategory/10000",
"id": "10000",
"name": "FIRST",
"description": "First Project Category"
}
},
{
"self": "http://www.example.com/jira/rest/api/2/project/ABC",
"id": "10001",
"key": "ABC",
"name": "Alphabetical",
"avatarUrls": {
"48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10001",
"24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10001",
"16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10001",
"32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10001"
},
"projectCategory": {
"self": "http://www.example.com/jira/rest/api/2/projectCategory/10000",
"id": "10000",
"name": "FIRST",
"description": "First Project Category"
}
}
]
使用this (http://jsonutils.com/)将其转换为。net类。但是,我想在WCF服务中使用这个类。我需要添加数据联系人和数据成员吗?
我得到头像url如下(这是几行代码从我的类):
public class AvatarUrls
{
public string 48x48 { get; set; }
public string 24x24 { get; set; }
public string 16x16 { get; set; }
public string 32x32 { get; set; }
}
如果我设置"属性属性"作为数据成员。结果显示为:
[DataContract]
public class AvatarUrls
{
[DataMember(Name="48x48")]
public string 48x48 { get; set; }
[DataMember(Name="24x24")]
public string 24x24 { get; set; }
[DataMember(Name="16x16")]
public string 16x16 { get; set; }
[DataMember(Name="32x32")]
public string 32x32 { get; set; }
}
我在这里得到的错误是:1.找不到类型或名称空间名称"x48"(缺少汇编引用)2. String ->期望的类、委托、枚举、接口或结构
只是想知道,我可以在我的WCF代码中这样使用吗?我有点糊涂了,这对不对?怎么了?我错过什么了吗?请帮助。
48x48
和类似的不是有效的标识符,将它们更改为类似Icon_48x48
的东西,并以相同的方式使用DataMember属性。