gpt4 book ai didi

JSON .Net 错误地生成架构(类型为数组)

转载 作者:行者123 更新时间:2023-12-02 15:47:36 24 4
gpt4 key购买 nike

当使用 JSON.Net JsonSchemaGenerator 为我的对象生成 JSON 架构时:

Public Class Host
Public Property uid() As String
End Class

它将类型属性生成为字符串数组:

{
"type": "object",
"properties": {
"uid": {
"required": true,
"type": [
"string",
"null"
]
}
}
}

正确的 JSON 架构应该是:

{
"type": "object",
"properties": {
"uid": {
"required": true,
"type": "string"
}
}
}

有人见过这个吗?

最佳答案

它不是一个字符串数组,它是一个nullable string .

{ "type": [ "string", "null"] } 表示值是字符串或 null。字符串数组将是 { "type": "array", "items": { "type": "string"} }

关于JSON .Net 错误地生成架构(类型为数组),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17663084/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com