【发布时间】:2021-12-22 18:12:13
【问题描述】:
既然我们只能在 jsonb 列中存储 json 对象的数组,那么为什么要使用 jsonb[]。 我试图通过简单地将 jsonb 对象数组从 jsonb 列复制到 jsonb[] 列来将数据插入 jsonb[] 中。但是出现错误“格式错误的数组文字:必须引入明确指定的数组维度”。
[
{
"SchoolsCode": "",
"SchoolsName": "",
"SchoolsType": "High School",
"ErrorMessage": null,
"SchoolsDegree": "Doctoral Degree",
"BiskDocumentID": "",
"FailedAttempts": 0,
"SchoolsDegreeID": 2,
"ChecklistsHidden": "Active",
"ChecklistsStatus": "Received",
"ChecklistsSection": "Official Transcript",
"ChecklistsSubject": "High School Transcript (Bloomingdale High School)",
"SchoolMailingAddress": {
"City": "Windham",
"Region": "ME",
"Country": "United States",
"ZipCode": "",
"AddressStreet1": "406 Gray Rd",
"AddressStreet2": null
},
"SchoolsConferredDate": "2018-05-01",
"DocumentInformationID": 1,
"SchoolsAttendedToDate": "2018-07-01",
"SchoolsAttendedFromDate": "2014-04-01",
"IsSalesforceUpsertSuccess": true,
"IsStatusReceivedFromMaterialsEndpoint": true
},
{
"SchoolsCode": "",
"SchoolsName": "Bloomingdale High Scho",
"SchoolsType": "High School",
"ErrorMessage": null,
"SchoolsDegree": "Doctoral Degree",
"BiskDocumentID": "",
"FailedAttempts": 0,
"SchoolsDegreeID": 6,
"ChecklistsHidden": "Active",
"ChecklistsStatus": "Received",
"ChecklistsSection": "Official Transcript",
"ChecklistsSubject": "",
"SchoolMailingAddress": {
"City": "Windham",
"Region": "ME",
"Country": "United States",
"ZipCode": "",
"AddressStreet1": "406 Gray Rd",
"AddressStreet2": null
},
"SchoolsConferredDate": "2018-05-01",
"DocumentInformationID": 2,
"SchoolsAttendedToDate": "2018-07-01",
"SchoolsAttendedFromDate": "2014-04-01",
"IsSalesforceUpsertSuccess": true,
"IsStatusReceivedFromMaterialsEndpoint": true
},
{
"SchoolsCode": "",
"SchoolsName": "Governors State University",
"SchoolsType": "High School",
"ErrorMessage": null,
"SchoolsDegree": "Bachelor's Degree",
"BiskDocumentID": "fwafhawolef",
"FailedAttempts": 0,
"SchoolsDegreeID": 4,
"ChecklistsHidden": "Active",
"ChecklistsStatus": "Missing",
"ChecklistsSection": "Official Transcript",
"ChecklistsSubject": "High School Transcript (Bloomingdale High School)",
"SchoolMailingAddress": {
"City": "Windham",
"Region": "ME",
"Country": "United States",
"ZipCode": "04062",
"AddressStreet1": "406 Gray Rd",
"AddressStreet2": null
},
"SchoolsConferredDate": "2018-05-01",
"DocumentInformationID": 3,
"SchoolsAttendedToDate": "2018-07-01",
"SchoolsAttendedFromDate": "2014-04-01",
"IsSalesforceUpsertSuccess": true,
"IsStatusReceivedFromMaterialsEndpoint": true
}
]
【问题讨论】:
-
jsonb[]几乎没有意义。将列的类型更改为jsonb,然后您可以直接插入您的值,没有任何问题。 -
为什么要使用 jsonb[] 我不知道有什么理由这样做。
-
是的,插入和检索过程完全适用于 jsonb 类型。
标签: c# arrays postgresql .net-core jsonb