Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.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
C# yaml到json的转换_C#_.net_Swagger_Yamldotnet - Fatal编程技术网

C# yaml到json的转换

C# yaml到json的转换,c#,.net,swagger,yamldotnet,C#,.net,Swagger,Yamldotnet,在为swagger模式实现yaml到json转换器的过程中,我遇到了一个问题:反序列化生成器的默认设置 var deserializer = new DeserializerBuilder().Build() 无法识别“整型”、“布尔型”类型。反序列化程序将这些类型转换为字符串。例如:我有yaml: EntityId: type: integer example: 1245 EntityIds: type: array items: $ref:

在为swagger模式实现yaml到json转换器的过程中,我遇到了一个问题:反序列化生成器的默认设置

var deserializer = new DeserializerBuilder().Build()
无法识别“整型”、“布尔型”类型。反序列化程序将这些类型转换为字符串。例如:我有yaml:

EntityId:
    type: integer
    example: 1245

EntityIds:
    type: array
    items:
        $ref: EntityId
    example: [152, 6542, 23]
转换的结果是:

"EntityId":{
  "type":"integer",
  "example":"1245"
},
"EntityIds":{
  "type":"array",
  "items":{
    "$ref":"EntityId"
  },
  "example":[ "152","6542","23"]
}
但如果我将输入yaml放入任何在线转换器,我会得到正确的json结果:

"EntityId": {
  "type": "integer",
  "example": 1245
},
"EntityIds": {
  "type": "array",
  "items": {
    "$ref": "EntityId"
  },
  "example": [
    152,
    6542,
    23
  ]
}
还包括布尔类型的行为


问题是如何设置反序列化程序以进行正确转换。

目前,YamlDotNet不支持此操作。正在进行支持工作,这将启用此功能,但尚未完成。

目前,YamlDotNet不支持此功能。正在进行支持工作,这将启用此功能,但尚未完成。

您有预计到达时间吗?您有预计到达时间吗?